-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
the following yaml will automatic create new network, then nginx2 can ping nginx1.
version: '3'
services:
nginx1:
image: nginx:alpine
container_name: "nginx1"
nginx2:
image: nginx:alpine
container_name: "nginx2"
but I don't want it to create new network , so I use the following yaml. it turns out that nginx2 can't ping nginx1.
it shows me: ping: bad address 'nginx1'.
version: '3'
services:
nginx1:
image: nginx:alpine
network_mode: "bridge"
container_name: "nginx1"
nginx2:
image: nginx:alpine
network_mode: "bridge"
links:
- nginx1
container_name: "nginx2"
but when you use the following code , nginx1 and nginx2 will add to default bridge network and nginx2 can ping nginx1.
docker run -d --name nginx1 nginx:alpine
docker run -d --name nginx2 --link nginx1 nginx:alpine
docker inspect nginx2 will show then the follwing code.
"Links": [
"/nginx1:/nginx2/nginx1"
],
so, is there a way to fix this problem when docker-compose use default bridge can't link other service?
muutech
Metadata
Metadata
Assignees
Labels
No labels