Service can't be reached by defined hostname
Problem
Given the following docker-compose.yml file: [code block] The following ping fails: [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Service can't be reached by defined hostname
If goal of Docker Compose is to make it easier for users to deploy a composition of services using Docker images and containers, then the file definition should be crystal clear. When a user defines a hostname to a service, it will expect that hostname to be resolvable from other services, specially when these services participate in the same network (as per my example). Since a service can hav
Trust Score
6 verifications
- 1
If goal of Docker Compose is to make it easier for users to deploy a composition
If goal of Docker Compose is to make it easier for users to deploy a composition of services using Docker images and containers, then the file definition should be crystal clear.
- 2
When a user defines a hostname to a service, it will expect that hostname to be
When a user defines a hostname to a service, it will expect that hostname to be resolvable from other services, specially when these services participate in the same network (as per my example).
- 3
Since a service can have multiple instances, it is just logical that when I defi
Since a service can have multiple instances, it is just logical that when I define a hostname to a service, that hostname resolves to multiple instances (thus using the new DNS feature in latest version).
- 4
If nothing of these can be implemented today, or should not be implemented at al
1. hostname should have restriction like container_name where one service instance only will exist. 2. hostname should not be allowed in the compose file because there is no value added to that rather creating confusion in users' mind.
Validation
Resolved in docker/compose GitHub issue #2925. Community reactions: 29 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep