Now that Docker is installed, let's run our first container. Here's the command we'll use.
docker run -it -p 3000:80 nginx
Breaking this command down:
docker- the Docker executable, which allows us to manage containers and images
run- allows us to run a command in a new container
-it- allocates a pseudo-TTY, an interactive bash shell connected to the container.
-p 3000:80- specifies an outward-facing port accessible to the host (
localhost) and its corresponding port within the container
nginx- the name of the image we want to run
If you go to http://localhost:3000 or http://127.0.0.1:3000, you should be met with the famous "Welcome to nginx!" page. You're now running a container that runs nginx (pronounced engine-x), a web server! If you check the terminal, you'll also see log output from the nginx.