nezhar / wordpress-docker-compose

Easy Wordpress development with Docker and Docker Compose
MIT License
1.84k stars 1.31k forks source link

Added links to allow db accessible in wordpress container. #20

Closed Aeyzaz closed 5 years ago

slhck commented 5 years ago

Is this really necessary? WordPress can be installed without this link, so apparently the container already has access to the database.

Aeyzaz commented 5 years ago

I have hosted multiple docker containers and connected them to two separate domains using nginx as reverse proxy server and i was not able to access the database in wordpress service. after adding link to db i was able to access the db service in wordpress container. Although a simple change but it can save someones' time.

nezhar commented 5 years ago

@Aeyzaz Thanks for your input.

According to the docker-compose docs this isn't really necessary as the containers get linked by default: https://docs.docker.com/compose/compose-file/#links

The MySQL service takes a bit longer to start on creation and the WordPress container cannot reach the database as it is still in setup. At some point the WordPress container may stop and you have to stop and start the containers. Can this be related to your issue?

Having links in the docker-compose.yml makes it a bit more verbose. But I have to agree, if it can solve such issues it is better to add it instead of wasting time :slightly_smiling_face:

Aeyzaz commented 5 years ago

No, as the yml file already has depends_on parameter set up the container still wasn't able to access mysql service by adding link it solved the issue.