CodeBlanks Logo Icon CodeBlanks

What is Docker?

Learn that Docker is a container-based platform and why it is used.

What is Docker?

Docker is a platform that runs an application together with everything it needs (libraries, runtime, configuration files) in an isolated package called a container. This removes the "it worked on my machine" problem: the same container behaves the same on the developer's laptop, on the test server and in the cloud.

docker run nginx      # runs the nginx web server with one command

The first command

On a machine with Docker installed, the first try is usually the hello-world image. If Docker can't find the image locally it downloads it from Docker Hub, creates a container, runs it, and the container stops once its work is done:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

This single command does all the steps of downloading, creating and running.

Practice Hello Docker

Write the command that runs a container from the hello-world image.

Starter code

terminal
# buraya yaz

Expected output

Hello from Docker!
This message shows that your installation appears to be working correctly.

Questions and answers

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

1 What is the main problem Docker solves?

  • Browser incompatibilities
  • An application not running the same way in every environment Correct answer
  • Code compiling slowly
  • Slow database queries

Explanation: A container packages the application with its dependencies; environment differences disappear.

2 Run a container from an image.

Question
docker ____ hello-world
Answer
docker run hello-world

Explanation: docker run creates and starts a new container from an image.

3 Match the concepts.

Term Meaning
Docker Container platform
container Isolated running process
Docker Hub Public image repository
hello-world Installation test image

All lessons in Beginner