问题原文
原帖链接 · Thomas · CC BY-SA 3.0
now that some of my server applications are packed into Docker containers, I'm trying to deploy them on my production servers. My containers should be accessible by IPv4 and IPv6 at the same time. Usually that is no problem: If you map container ports to host ports e.g. via docker-compose, Docker will use available IPv6 and IPv4 addresses.
My problem is: There is not only one IPv4 and IPv6 address available on my server, but multiple. My application container should only use one specific IPv4 address and one specific IPv6 address of the host. You can bind a container port to a IPv4-address by using the following docker-compose syntax:
ports:
- "127.0.0.1:8001:8001"
(See https://docs.docker.com/compose/compose-file/#ports)
Unfortunately I couldn't find any information how to do that with IPv6 addresses. Is there any way I can bind a container port to a single, specific IPv6 address on my Docker host?
已采纳解答
原帖链接 · BMitch · CC BY-SA 4.0
As of version 1.15 of docker-compose you can now use additional colons in the port definition for IPv6:
version: '3.3'
services:
app:
image: nginx
ports:
- "::1:8080:80"
The relevant issue can be found here: https://github.com/docker/compose/issues/2663
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
