Docker Run a Container

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will immerse yourself in a scenario set in the Victorian era, where you take on the role of an antiquities dealer. Your goal is to effectively transport and present historic artifacts using modern technologyโ€”specifically, leveraging Docker containers to streamline your operations.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("`Docker`")) -.-> docker/ContainerOperationsGroup(["`Container Operations`"]) docker/ContainerOperationsGroup -.-> docker/run("`Run a Container`") subgraph Lab Skills docker/run -.-> lab-271495{{"`Docker Run a Container`"}} end

Setting Up Your Docker Environment

In this step, you will begin by ensuring that your Docker environment is properly set up to run containers.

  1. Install Docker by executing the following commands in your terminal:

    sudo apt update
    sudo apt install docker.io
  2. Once Docker is installed, start the Docker service:

    sudo systemctl start docker
  3. Verify that Docker is running successfully:

    sudo systemctl status docker

Running a Hello-World Container

Now that your environment is set up, you will run your first Docker containerโ€”a simple "hello-world" example.

  1. Pull the "hello-world" image from Docker Hub:

    sudo docker pull hello-world
  2. Run the "hello-world" container:

    sudo docker run hello-world
  3. Check the output to ensure that the container ran successfully.

Deploying an Nginx Web Server

In this step, you will deploy an Nginx web server using a Docker container.

  1. Pull the Nginx image from Docker Hub:

    sudo docker pull nginx
  2. Run an Nginx container in detached mode, mapping port 80 on the host to port 80 on the container:

    sudo docker run -d -p 80:80 nginx
  3. Add a web service mapping from the top menu lab and set the port mapping. If the Nginx web server is running successfully, the lab environment will automate navigating to a random URL in the server lab.

Summary

In this lab, you have been introduced to the fundamental concepts of running Docker containers. By simulating a historical context and engaging as an antiquities dealer, you have gained practical experience in leveraging Docker's run capabilities, consolidating your understanding of this essential skill. This hands-on experience will prove invaluable in deploying and managing various containers in real-world scenarios.

Other Docker Tutorials you may like