Reputation: 1506
I have been using a docker compose file to run a development environment for a microservices architecture that in production is deployed to kubernetes, so I use links
to map k8s provided domain names to the compose service names. e.g
links:
- "kafka:kafkadc-c44b-44.default.svc.cluster.local"
All works well when using docker-compose
. But when using the new docker compose
(note no hyphen), the containers are unable to comminicate with eachother. Kafka connections fail. HTTP requests fail.
Are there any changes between the docker cli version of compose, and the old docker-compose
command. I cann't see a version of docker compose without the hypen, but with I have the following version information:
docker-compose version 1.29.0, build 07737305
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h 22 Sep 2020
Upvotes: 1
Views: 276
Reputation: 2484
You can use hostname
to specify a hostname for the container within its network or you can use an alias
if you need a hostname per network.
e.g.
db:
image: mysql:5.7
container_name: mycontainername
hostname: myhostname
networks:
default:
aliases:
myalias
Upvotes: 1