Problem
I have projects with a configuration docker-composewith the same configuration (PHP, MySQL, nginx). When I run one project with docker-compose up, the problem does not arise, but I need to switch between them several times a day for development.
Problems:
- single port sharing configuration for nginx
- share configuration for default database and connection (name and users)
- domains for each project
I have
At the moment
Now just run upit down -vevery time. Basically, the project is on the same version of PHP (should be) and MySQL.
Ideas
Load balancer
- workspace, docker-compose loadbalancer, , MySql DB - .
?
Update
: '2.1'
dev
services:
app:
image: ${PHP_IMAGE}
volumes:
- ${COMPOSE_DIR}/../../:/var/www:cached
- ${COMPOSER_HOME}:/root/.composer:cached
depends_on:
- db
environment:
- SYMFONY_ENV=${SYMFONY_ENV-prod}
- SYMFONY_DEBUG
- SYMFONY_HTTP_CACHE
- SYMFONY_HTTP_CACHE_CLASS
- SYMFONY_TRUSTED_PROXIES
- DATABASE_USER
- DATABASE_PASSWORD
- DATABASE_NAME
- DATABASE_HOST=db
web:
image: ${NGINX_IMAGE}
volumes_from:
- app:ro
ports:
- "8080:80"
environment:
- SYMFONY_ENV=${SYMFONY_ENV-prod}
- MAX_BODY_SIZE=20
- FASTCGI_PASS=app:9000
- TIMEOUT=190
- DOCKER0NET
command: /bin/bash -c "cd /var/www && cp -a doc/nginx/ez_params.d /etc/nginx && bin/vhost.sh --template-file=doc/nginx/vhost.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
db:
image: ${MYSQL_IMAGE}
volumes:
- ${COMPOSE_DIR}/entrypoint/mysql:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=1
- MYSQL_USER=$DATABASE_USER
- MYSQL_PASSWORD=$DATABASE_PASSWORD
- MYSQL_DATABASE=$DATABASE_NAME
- TERM=dumb
, , PHP. nginx, .
@ , .
-.
1
2
- , docker-compose
- , docker-compose
- , docker-compose
.
- , - .