0

I do the docker tutorial document at part 3. Because my computer is windows, I use the docker toolbox. Before part 3, I use the command docker run -p 8080:80 test, and it can connect to 192.168.99.100:8080, that's successful.

But when creates a swarm and deploies the docker-compose.yml, it was a success.

ID                  NAME                MODE                REPLICAS            IMAGE                         PORTS
uskmy4zkflhf        testswarm_web       replicated          5/5                 ***/get-started:test   *:6666->80/tcp

However, when I used 192.168.99.100:6666 to connect, the page could not be displayed, and using ping, I could see that 192.168.99.100 could be connected.

When I uninstall the toolbox and then reinstall it, I deploy it only once, which means that the entire program sets the port only once and no containers occupy it. It doesn't work in this case either.

What's the problem with that?

Vision Yang
  • 175
  • 1
  • 1
  • 8

1 Answers1

0

The port publishing mechanism works differently when you use standalone or swarm mode. If you're using a compose file in swarm mode, you should not be using docker-compose up but docker stack deploy instead.

I would suggest taking it step-by-step, instead of using the stack deploy or compose approach, first learn to use the docker service create command, and take it one service at a time.

Try docker service create --name proxy --publish 8080:80 nginx and see if you can reach NGINX in 192.168.99.100:8080. Once you're there, try scaling it with docker service update --replicas=5 proxy.

Once you feel comfortable with this, you should be able to tell what's going on with more precision.

If you want to delve deeper into how por publishing works in swarm mode, I suggest this docs article.

gvilarino
  • 672
  • 5
  • 12