I am new to docker and trying to dockerize my laravel app (version 5.1)
Following is my docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
ports:
- "3307:3306/tcp"
volumes:
- test_db:/var/lib/test_db/data
web:
build:
context: ../
dockerfile: deploy/Dockerfile
args:
APP_ENV: "local"
environment:
APP_DEBUG: "true"
DB_HOST: "db"
DB_DATABASE: "test"
DB_USERNAME: "root"
DB_PASSWORD: "root"
ports:
- "443:8000/tcp"
volumes:
- ../:/var/www/html
links:
- db
depends_on:
- db
restart: on-failure:10
container_name: test_web
volumes:
test_db:
When I execute docker-compose up command, I get the following error
[PDOException]
test_web | SQLSTATE[HY000] [2002] Connection refused
As I have set 10 retries so it ultimately connects and migrations are executed but I have the following issues:
- Why the connection do not get established instantly or within few retries?
- I am using named volumes but the data dont seem to get persistent. Everytime when i run
docker-compose up, migrations are executed and the data gets overwritten
Please let me know what are the possible issue behind the above two issues
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire