Alexander Presber
Alexander Presber

Reputation: 6635

docker-compose: make container available under subdomain

I want a container to be reachable as host-a as well as sub.host-a from another container host-b in the same network.

What I tried in my docker-compose.yml (inspired by this blog post):

version: '3'
services:
  host-a:
    networks:
      my_network:
        aliases:
          - sub.host-a
    ...

  host-b:
    networks:
      - my_network
    ...

networks:
  my_network:

Resolving host-a works from host-b, but resolving sub.host-a does not.

How can this be achieved?

Upvotes: 8

Views: 2959

Answers (1)

Alexander Presber
Alexander Presber

Reputation: 6635

My bad.

Actually, the aliases are working exactly as expected: The first container can be accessed from other containers as sub.host-a.

No other changes needed.

Upvotes: 4

Related Questions