Now that we have Docker installed, we are going to quickly test our installation by downloading, running and connecting to a NGINX container.
A note on Docker commands
Docker 1.13 introduced a slightly altered set of command line instructions for interacting with containers and images. As this syntax will eventually become the new standard we will be using it throughout this book. For more information on the CLI restructure, please see the Docker 1.13 announcement blog post at https://blog.docker.com/2017/01/whats-new-in-docker-1-13/
To download and launch the container all you need to do run the following commands from your terminal prompt;
docker image pull nginx docker container run -d --name nginx-test -p 8080:80 nginx
The first command pulls the NGINX container image from the Docker Hub, and the second command launches our NGINX container, naming it nginx-test
mapping port 8080
on your machine to port 80
on the container.
You can check that the container is running using the following command:
docker container ps
Opening your browser and going to http://localhost:8080/
should show you the default Welcome to NGINX page.
As you can see from the following screens, the process is the same when using Docker for Mac:
Or Docker on Ubuntu 16.04:
As you can see from the screens above, the result of us running the same command on each of the three platforms is exactly the same.
Once you have tested launching a container you can tidy up afterwards by running the following commands to stop and remove the container and then delete the image:
docker container stop nginx-test docker container rm nginx-test docker image rm nginx
18.221.18.145