Answer the question
In order to leave comments, you need to log in
How can a group of containers, in docker-compose, be associated with one of the host's external IPs?
There is a classic bunch of nginx/php-fpm/mariadb/postfix containers configured in docker-compose. So, the task is to associate this group with a specific external IP of the host machine, so that the IP is connected not only to the input, but also to the "exit".
NGINX is now set up simply:
ports:
- ext_ip:80:80
- ext_ip:443:443
Answer the question
In order to leave comments, you need to log in
In short, I found a solution.
I use ipv6, so there are some nuances. The version of docker-compose must be from the 2.x series, as in version 3, the enable_ipv6 setting is not yet available. You also need to add the robbertkl/ipv6nat container to help with ipv6 operation.
___IPv6___ is your external ip v6
___IPv4___ is your external ip v4
In docker-compose.yml,:
version: '2.4'
services:
#...
ipv6nat:
container_name: ipv6nat
restart: always
image: robbertkl/ipv6nat
privileged: true
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /lib/modules:/lib/modules:ro
networks:
default:
driver: bridge
driver_opts:
com.docker.network.bridge.host_binding_ipv4: "___IPv4___"
com.docker.network.bridge.enable_ip_masquerade: "false"
com.docker.network.bridge.host_binding_ipv6: "___IPv6___"
enable_ipv6: true
ipam:
driver: default
config:
#наши ip, которые будут выдаваться контейнерам, указанным внутри docker-compose
- subnet: 172.16.238.0/24
- subnet: 2001:3984:3989::/64
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question