Basic Docker setup to enable a quick start for a LAMP Stack based on CentOS 7 with MariaDB
- Basic setup
- Expose services
- MySQL proper volume mount
docker-compose up -d
Service | Port | Notes |
---|---|---|
Apache | 80 | --- |
MySQL | 3306 | --- |
- Apache to port 80
- MariaDB to port 3306
You'll need to configure your application to use any services you enabled:
Service | Port | Notes |
---|---|---|
www | 80 | --- |
db | 3306 | --- |
- Start containers in background:
docker-compose up -d
- Start containers on foreground:
docker-compose up
. You will see a stream of logs for every container running. - Stop containers:
docker-compose stop
- Kill containers:
docker-compose kill
- View container logs:
docker-compose logs
- Execute command inside of container:
docker-compose exec SERVICE_NAME COMMAND
whereCOMMAND
is whatever you want to run. Examples:- Shell into the PHP container,
docker-compose exec www bash
- Run symfony console,
docker-compose exec www bin/console
- Open a mysql shell,
docker-compose exec db mysql -uroot -pCHOSEN_ROOT_PASSWORD
- Shell into the PHP container,
- Run composer outside of the php container, as doing so would install all your dependencies owned by
root
within your vendor folder. - Run commands (ie bash's console) straight inside of your container. You can easily open a shell as described above and do your thing from there.
- Subfolders called 'www', 'mysql' and 'mysql-dump' are need in order to let container work properly.