How can I connect to a Docker container from host and from another container by same hostname?

I am developing and deploying a Symfony web-application with Docker and Docker Compose (and Swarm). My problem is when running composer update and similar composer commands as well as the bin/console Symfony-utility. When running such commands on the host machine, it tries to run the autoscripts to clear the cache. The cache container (Redis) can’t be connected to, and this produces an error. The reason the cache can’t be connected to is that the connection details are set up for the app container which can use the cache container’s hostname, which the host machine can’t.

Is there a solution where I can keep my app configuration, while still being able to connect to the cache from the host (e.g. when running bin/console and composer update)?

Additional note: I am using a bindmount volume from my app code on the host into the app container.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *