Running a container with Docker
As was mentioned earlier, Docker gives us a standardized way of packaging up a container image. These container images can be shared through Docker registries, and Docker Hub (https://hub.docker.com/) is a commonly used registry for publicly available images. In this section, we will run a container with the nginx
web server using the docker run -d --name docker-nginx -p 8080:80 nginx
command as follows:
$ docker run -d --name docker-nginx -p 8080:80 nginx Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx 8559a31e96f4: Already exists 1cf27aa8120b: Downloading [======================>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ]Â Â 11.62MB/26.34MB ...
The last part of the command we just ran tells Docker what container image we want to run (nginx
). This snippet of output shows...