Accessing Docker containers over the network

Run the container so that it can be reached on port 80

  1. The ports a container can be accessed on are determined when the container is initially ran with the -p flag.
    • The following command will run our image created in the previous lab and forward traffic on port 8080 of our host to the docker container on port 80. You can get your image name with docker images. If you followed our example prior, the image name will be dopensource/nginx.
    docker run -dit -p 8080:80 <image name>
  2. Your container should now be bound to port 8080 on your host system.
    • Try opening up a browser and typing in http://:8080
    • You should see the default nginx page, which is being served by the nginx container we created earlier.