NGINX Modern Apps > Class 2 - NGINX Plus CI/CD Lab > Module 1: Creating docker images for NGINX Plus Source | Edit on
Lab 3 (OPTIONAL): Pull and run a Docker image from our private Docker Registry¶
If you want some practice with Docker, this task is an excellent opportunity to practice basic Docker commands. In this task, we will pull and run a docker container on our Staging server, a “Docker host.”
We will pull an image from our private docker registry, run a container, and use volumes to persist data.
Note
For more self-paced, hands-on-tutorial, try out the Docker 101 tutorial
Open an SSH Shell to the Staging Server using git bash for windows.
Git Bash is a bash shell emulator, similar to what you see natively on Linux and Unix machines. If the git console font is too small to read, use Ctrl+ “+” to increase the font
Once git bash for windows is open, run the following command to SSH into the Staging server:
The web shell will open as
centos
user. Make sure you are in in the provided project folder with NGINX Plus configurations in/home/centos/nginx-plus-docker-base
Pull an image from our private docker registry using the
docker pull
command. Run the following command below to pull our NGINX Plus image built on Alpine Linux 3.10, if you want to run another image, you can copy the Docker image location from the Gitlab Container registry page from the nginx-plus-dockerfiles repository
Which should produce the following output:
alpine3.10: Pulling from f5-demo-lab/nginx-plus-dockerfiles 4167d3e14976: Already exists d515ef1b2c63: Pull complete 72886512006a: Pull complete 7f39e3ca1721: Pull complete ea3c7cd8c3af: Pull complete 7385769c7c40: Pull complete Digest: sha256:400dd9e21e963629fc3d974261b1b6668b5c822009ddb183ddaa0631c2ae4165 Status: Downloaded newer image for registry.gitlab.f5.local/f5-demo-lab/nginx-plus-dockerfiles:alpine3.10 registry.gitlab.f5.local/f5-demo-lab/nginx-plus-dockerfiles:alpine3.10![]()
Note
If you receive an error of “dial tcp: lookup gitlab.f5demolab.com on 10.1.255.254:53: no such host”, try the command again. Sometimes, it resolves on its own. If you still get the error after multiple tries, ask a lab assistant for help.
Run a container using the downloaded docker image from the previous step. We will also map ports
9000
and9080
on the docker host to ports80
and8080
on the container, and also mount the local nginx configurations to the containerYou can see the container is running on the mapped ports. When running
docker ps
you may see it running alongside other containers. The first value is theCONTAINER ID
we will need this value later to shut down the containerWe can now test the NGINX Plus container by making a HTTP request using
curl
. We should get our test reponse page back:
Which should produce the following output:
After finishing testing, we can now stop the container using
docker stop [CONTAINER NAME]
. Since we named our containertest
, we can stop and remove this container using the following command:When we run
docker ps
again you will see that the container is no longer running