How to Deploy an nginx Container with Docker on Linode

Updated by Linode Contributed by Jack Wallen

Contribute on GitHub

Report an Issue | View File | Edit File

How to Deploy Docker Containers

What is a Docker Container?

According to, a container is a “lightweight, stand-alone, executable piece of a software package that includes everything needed to run it: code, runtime, system tools, system libraries, and settings.” A containers isolates software from its surroundings and is created from the images pulled from a Docker registry. For example, you can pull the nginx image and create as many containers from it as needed.

Docker Command Syntax

Deploy a Docker container using the following syntax:


It consists of:

  • CONTAINER-NAME: The name you give the container.
  • NETWORK_PORT: A port available to the network.
  • CONTAINER_PORT: The port the container will listen on.
  • IMAGE NAME: The name of the image to be used for the container.

Deploy a Container

This example will create an nginx container with port 80 exposed, using the official nginx image.

  1. Confirm the current, existing official image:

    docker images

    In this screenshot, the nginx image is two weeks old:


  2. Update the original image with docker pull nginx as shown in the How to Install Docker and Pull Images for Container Deployment guide. Run docker image again to confirm the update:

    Docker Pull New nginx Image

  3. Deploy the container:

    docker run --name docker-nginx -p 80:80 -d nginx

    This will show the newly created ID for the container. Note that the -d, detach, option returns you to the prompt:

    Docker run

  4. Confirm that the container is running:

    docker ps -a
  5. Navigate to your Linode’s IP address to see the default nginx welcome message:

    Welcome to nginx

How to Stop and Delete Containers

  1. Stop the container by using the first few characters of the container ID (e468 in this example):

    docker stop e468
  2. Delete the container by using the rm command and the same container ID:

    docker rm e468

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

Join our Community

Find answers, ask questions, and help others.

comments powered by Disqus

This guide is published under a CC BY-ND 4.0 license.