I would like to run two projects using the nginx-proxy network. When I start only one project, it works normally. But when I start both, the result is very intermittent. If I press F5 it says it has failed to connect to the mysql service. If I press F5 again it says there was an error in the query. Sometimes it works normal. But if I press F5 to stop working again.
Taking advantage of the issue, I would like to know if it is the best way to run multiple projects on the same server. Or it's just a solution for anyone who wants to run multiple projects on the same server because the best solution is a docker project per server. I'm kind of confused about that.
Here my docker-compose.yml. The second project is similar changing ports and project paths only.
version: "3.1"
services:
memcached:
image: memcached:alpine
container_name: project-memcached
mysql:
image: mysql:5.6
container_name: project-mysql
working_dir: /application
volumes:
- .:/application
- ./phpdocker/mysql-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=project
- MYSQL_USER=project
- MYSQL_PASSWORD=docker
ports:
- "33066:3306"
webserver:
image: nginx:alpine
expose: [80]
restart: always
container_name: project-webserver
working_dir: /application
volumes:
- .:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
environment:
- VIRTUAL_HOST=project.local
php-fpm:
build: phpdocker/php-fpm
container_name: project-php-fpm
working_dir: /application
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
networks:
default:
external:
name: nginx-proxy
docker-compose.yml for proxy:
version: "3.1"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
default:
external:
name: nginx-proxy
Thanks advance!
Hey @Soufraz, I have a similar issue with 2 projects running at the same time. Could you share the solution to your problem? I know it's a long shot but it might help me. Thanks.
I have the same similar issue with 2 projects. I think it's only database that make data random. Any explain ? Volumes or network ? Thanks
Most helpful comment
Hey @Soufraz, I have a similar issue with 2 projects running at the same time. Could you share the solution to your problem? I know it's a long shot but it might help me. Thanks.