Docker sq
Docker Fundamentals - Getting Started

Publishing a Service

PRO
Outline

Publishing a Service

To run a server inside a container go to hub.docker.com and search for nginx.

Run docker container run nginx

To access the webserver that is running inside the container, you need to puplish it first. Quit using Control+C and restart it with the -p flag. This will create a port mapping. Your new command should read docker container run -p 80:80 nginx where 80:80 represents the local port being mapped to the container port you want.

You can see the results of this command if you go to your browser and enter "localhost" in the address field. You can also view the output of nginx back in your shell.

Quit using command + C and restart the container this time mapping to localport 8080 by using the command docker container run -p 8080:80 nginx. This will allow you to talk to nginx in the browser by entering "localhost:8080" in the address bar.

If you’re using docker machine you cannot access with localhost, you need to use the IP address of the docker machine.

 

I finished! On to the next chapter