Containers 101 – Run a Container with Docker

Docker is an engine to run containers from a Windows or Linux command line. A container is simlar to a VMware image or a template. Most containers already have an application installed but you can also use base OS images to build your own application. In this exercise we will deploy a container image with a pre-built web server running a simple web page.

Pre-reqs:

  • A Machine Running Docker see my guide here

By default, Docker is not running in a new Photon OS VM, type the following and see

docker ps

Start docker with the following command

systemctl start docker

Type the command again and see that Docker is running but there are no containers on the system yet

docker ps

That command only started docker in this session, run the following so that docker starts every time you power on this Photon VM

systemctl enable docker

Run the following to view any images on the system

docker images

There are no images so use the following command to pull one

docker pull public.ecr.aws/m0z6y2h1/nginx:latest

Type the following command again and see the new image you pulled is ready

docker images

Run the image as a container with the following command

docker run -d -p 80:80 public.ecr.aws/m0z6y2h1/nginx:latest

Now open a web browser to the ip address of your photon VM. NOTE: it is the same address you are using to SSH to the Photon VM

Yay. you successfully deployed your first Web Server Container! Add that to your resume!

To stop the container get the Container ID with the following command and copy it to the clipboard

docker ps

Type the following command with the container ID you copied earlier

docker stop b814e20c60e3

Try the Web Site again and notice it is down

In our next lesson you will create your own container and run it with docker.

Remember sharing is caring!

4 Replies to “Containers 101 – Run a Container with Docker”

  1. Pingback: Containers – 101 – Pre-Work | VMtoCloud.com

  2. Pingback: Containers 101 – Create a Contaner with Docker | VMtoCloud.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.