FG
☁️ Cloud & DevOpsDocker

Service can't be reached by defined hostname

Freshover 4 years ago
Mar 14, 20260 views
Confidence Score78%
78%

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

Canonical Fix
High Confidence Fix
74% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: Service can't be reached by defined hostname

Low Risk

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

74

Trust Score

6 verifications

100% success
  1. 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. 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. 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. 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

Worked: 6
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainersstale