Lesson 1.2

Running your first container

Running a container starts it from an image with the arguments you supply: which ports to publish, which directories to mount, which environment variables to pass.

6mBeginner27.1k students

Overview

The handful of commands you will use daily

Running a container starts it from an image with the arguments you supply: which ports to publish, which directories to mount, which environment variables to pass. Everything else is a variation on that.

Publishing a port maps a host port to a container port. Forgetting it is the reason a service that is definitely running is definitely not reachable.

Executing a shell inside a running container is the main debugging tool. Note that many minimal images have no shell at all, which is a deliberate trade-off you will meet later.

In this lesson you will:

  • Run, list, and remove containers
  • Publish a port and mount a directory
  • Get a shell inside a running container

Resources

Previous Lesson
Next Lesson
Running your first container — Docker Essentials — Vertex