Chapter

Images and containers

Understand images vs containers, and learn to run, list, stop and remove them.

Docker Basics 5 Lessons from courses

About this chapter

Now that Docker is running, let's get comfortable with the two core ideas - images and containers - and the everyday commands you'll use to manage them.

Lessons from courses

  1. 1 Images vs containers Docker image vs container explained with a simple analogy: an image is the read-only template, a container is a running instance of that image.
  2. 2 Running containers Learn how to run Docker containers with docker run: start them in the background with -d, name them with --name, and map ports with -p.
  3. 3 Listing and stopping containers Manage Docker containers from the command line: list them with docker ps, stop with docker stop, and remove with docker rm and the --rm flag.
  4. 4 Managing images Manage Docker images with docker pull, docker images and docker rmi, and learn how image tags and Docker Hub versions work in practice.
  5. 5 Working inside a container Open an interactive shell inside a Docker container: use docker run -it for a new container and docker exec -it bash to enter a running one.
Docker Basics Go to course