CodeBlanks Logo Icon CodeBlanks

Summary - What is Docker

Combine Docker's core concepts to write a container definition.

Summary: what Docker is

In this group:

  • Docker runs an application with its dependencies inside a container.
  • A container shares the host kernel; it is lighter and faster than a VM, and its isolation comes from namespaces and cgroups.
  • An image is a read-only template; a container is its running instance and carries its own writable layer.
  • The CLI sends commands to the daemon; the daemon pulls images from the registry.
  • One-off tools can be run with --rm.
docker pull nginx
docker run -d --name web --memory 256m nginx
docker run --rm alpine echo merhaba

Practice All together

Write three commands: pull the alpine image; start a container from it that runs echo merhaba and is deleted when done; finally start a container named web from the nginx image running in the background.

Starter code

terminal
# buraya yaz

Sample solution

terminal
docker pull alpine
docker run --rm alpine echo merhaba
docker run -d --name web nginx

Expected output

Status: Downloaded newer image for alpine:latest
merhaba
5c6d7e8f9a01

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What happens to a file created inside a container when the container is removed?

  • It is deleted together with the writable layer Correct answer
  • It is saved into the image
  • It is uploaded to Docker Hub
  • It is moved to the host desktop

Explanation: Persistent data needs a volume.

2 Start the container in the background.

Question
docker run ____ --name web nginx
Answer
docker run -d --name web nginx

Explanation: -d (detached) releases the terminal.

3 Match.

Term Meaning
image Template
container Instance
dockerd Daemon
--rm Automatic removal

All lessons in Beginner