Repaso
EspaƱol
Cloud & DevOpsFoundationsOPS-80

What is the difference between a Docker image and a container?

Options

  1. The image is a read-only template; the container is a running instance (Correct option)
  2. The image is a running program, and the container is just a file
  3. They are the same thing, only named differently by each tool
  4. The image is a database, and the container is a server

Answer

The image is the read-only template; the container is a running instance created from it

Why

Think of the same relationship as class and object, or recipe and dish.

You build an image from a Dockerfile (the instructions). You run it with docker run, and each run creates a container. You can start many containers from one image.

Images are stored in a registry such as Docker Hub.

docker build -t my-app .      # build an image
docker run -p 8080:8080 my-app  # start a container from it
docker ps                       # list running containers

Remember

Image = template. Container = running instance.

Key terms

Practice this question in Repaso