简体   繁体   中英

i can't access container in a docker

I am running several services on my CentOS 7 Linux server. Nginx and netdata are being run as root and are working well.

I started Portainer as a Docker container:

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer

I can connect to the Portainer port locally with telnet localhost 9000 . But, when I try to telnet ip 9000 from an external client PC on the same network, it doesn't connect.

The Linux server does not have a firewall. Nginx, netdata, and myapp that are not running in Docker work fine. In short, all other services can be accessed from a Linux server without a firewall, but Docker's internal container service is inaccessible.

What do I need to change to be able to reach the container?

You have to disable you ipv6

add this links to /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1 
net.ipv6.conf.default.disable_ipv6 = 1

to effect those

sysctl -p

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM