I have following docker-compose.yaml file
version: "3.9"
services:
box1:
hostname: box1
build:
context: .
dockerfile: box.Dockerfile
networks:
testing:
ipv4_address: 172.28.1.10
command: |
/bin/sh -c 'while true; do sleep 1; done'
box2:
hostname: box2
build:
context: .
dockerfile: box.Dockerfile
networks:
testing:
ipv4_address: 172.28.1.20
command: |
/bin/sh -c 'while true; do sleep 1; done'
box3:
hostname: box3
build:
context: .
dockerfile: box.Dockerfile
networks:
testing:
ipv4_address: 172.28.1.30
command: |
/bin/sh -c 'while true; do sleep 1; done'
networks:
testing:
driver: macvlan
driver_opts:
parent: eth0
ipam:
driver: default
config:
- subnet: 172.28.1.0/24
gateway: 172.28.1.1/
aux_addresses:
box1: 172.28.1.10
box2: 172.28.1.20
box3: 172.28.1.30
I tried every combination and hint on internet, but no matter what I try, docker compose is assigning another IP addresses to containers then those I am using in specification.
When I try docker exec box_1 /bin/sh -c 'ifconfig' or dig for dns of another container, I am getting random IP addresses instead of those that are set for every container.
I am running docker desktop for mac 3.3.1 (63152)
I had a similar problem when using docker compose up on macOS. Using docker-compose up (note the - sign) resolved it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With