Docker Community Forums

Share and learn in the Docker community.

Use Hosts IPV4 - without network mode host

Hello,

I got one question. I wrote a docker-compose.yml. It contains several services. But one of the services needs to use the IPV4 of the hosts machine. How can use the IPV4 of the docker host ? Is that possible without having to set the ned mode to host ? I dont want that program to be able to access the hosts file system.

Thank you for your help.

This is a part of my docker-compose.yml:

container:

container_name: name

image: xx/xx

networks:

pub_ip6_block_net:

ipv6_address: 2a0a:xxxx:x:xxx::x

links:

- xxxx

dns:

- 1.1.1.1

ports:

- "xx:xx/udp"

volumes:

- './etc/xx:/etc/xx/'

- './lib/xx:/lib/xx'

sysctls:

- net.ipv6.conf.all.disable_ipv6=0

- net.ipv6.conf.all.forwarding=1

cap_add:

- NET_ADMIN

- SYS_MODULE

restart: unless-stopped