0

I am trying to run an nginx image inside a Docker container. I have tried these steps

  • ssh inside ubuntu docker image docker run -v /var/run/docker.sock:/var/run/docker.sock -it ubuntu:latest bash
  • Installed Docker
  • Run Nginx image docker run -d -p 80:80 nginx

curl localhost:80 gives Connection refused

1 Answers1

0

Mapping docker.sock to containers means you will be using the docker daemon of the host machine, not the container's.

So when you run docker run -d -p 80:80 nginx command, the nginx container is created and run in host machine (sibling of the ubuntu container). Hence, 80:80 maps in the host machine.

Validate this by running docker ps in ubuntu container and in the host machine. The result should match. And I guess, you can do curl localhost in the host machine and hit the nginx server as well.

mixth
  • 636
  • 5
  • 16