nginx web server.-p flag.nginx web server.-p flag.docker run command to start a container named mynginx using the nginx image without any port mapping.Use docker run --name mynginx -d nginx to start the container in detached mode.
docker run command to map port 8080 on your computer to port 80 inside the container using the -p flag.Use -p 8080:80 to map ports.
docker run command with the -p 8080:80 flag and container name mynginx to start the nginx server with port mapping.Use the same command as before to run the container.
docker ps command to list running containers and show the port mapping for mynginx.Use docker ps to see running containers and their port mappings.
What does the -p flag do in the docker run command?
-p flag-p flag is used to connect a port on your computer (host) to a port inside the Docker container.-p flag = port mapping [OK]Which of the following is the correct syntax to map host port 8080 to container port 80?
docker run -p ??? image_name
-p host_port:container_port, so the host port comes first.-p 8080:80.What will happen if you run this command?docker run -p 5000:80 nginx
Then open http://localhost:5000 in your browser?
http://localhost:5000 accesses the container's port 80 service, showing Nginx's default page.What is wrong with this command?docker run -p 80:8080 myapp
The app inside the container listens on port 8080.
You want to run two containers from the same image that both expose port 80 inside the container. How can you map their ports so both are accessible on your host machine?
Pass the test and this pattern moves unknown