Does Compose reserve an IP Address if specified by a service in the compose file? #11564
Unanswered
mickelsonmichael
asked this question in
Q&A
Replies: 1 comment
-
Doesn't seem so: services:
s1:
image: bash
init: true
tty: true
s2:
extends: s1
profiles:
- later
networks:
default:
ipv4_address: 172.42.0.1
networks:
default:
ipam:
config:
- subnet: 172.42.0.0/31
$ docker compose up -d --wait
[+] Running 1/2
⠙ Network net_default Created 1.1s
✔ Container net-s1-1 Healthy 1.0s
$ docker compose run s2
ERRO[0000] error waiting for container: context canceled
Error response from daemon: no available addresses on this pool
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a
compose.yml
file of multiple containers, one of which requires the IP address of another (there is not currently a way to utilize hostname, it must be the IP).To get around this, I define a network with a subnet, and give the container an IP in that range. See below for an abbreviated version of my compose.
My question is: Does docker compose reserve the IP address I have defined, or can another container take the IP if it is created first? In other words, if
serviceB
in the example is created and assigned an IP beforeserviceA
is assigned its IP, canserviceB
"steal" the reserved IP fromserviceA
or does Compose ensure that the IP Address is not used by another container?Asked this question on SO as well but it got downvoted for being off topic
Beta Was this translation helpful? Give feedback.
All reactions