Docker - Access Local Services
Learn how to access host servcies from a docker container.
Sometimes, having a Dockerized project, we might need to access local sevices like Redis, MySql or PostgreSQL.
This use case is supported by Docker when we set in the environment the hostname to host.docker.internal instead of using the traditional localhost
or 127.0.0.1
witch might lead to runtime errors like this:
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Some well-known local services we can access from a Docker Container
- Redis: port
6379
, hostname host.docker.internal, instead oflocalhost
- MySql: port
3306
, hostname host.docker.internal, instead oflocalhost
- Postgresql: port
5432
, hostname host.docker.internal, instead oflocalhost
✅ Resources​
- 👉 Read more about Docker
- 👉 Access AppSeed for more starters and support
- 👉 Deploy Projects on Aws, Azure and DO via DeployPRO