Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 4.15 KB

1.md

File metadata and controls

75 lines (49 loc) · 4.15 KB

Exercise 1: Getting started

In this section you will install Docker and run your very first container.

Terminology

In this section, you will see a lot of Docker-specific jargon which might be confusing to some. So before you go further, let's clarify some terminology that is used frequently in the Docker ecosystem.

  • Images - The file system and configuration of our application which are used to create containers. To find out more about a Docker image, run docker inspect alpine. If you do not have the alpine image this command will fail. You can use the docker pull command to download the alpine image. When you executed the command docker run hello-world, it also did a docker pull behind the scenes to download the hello-world image.
  • Containers - Running instances of Docker images — containers run the actual applications. A container includes an application and all of its dependencies. It shares the kernel with other containers, and runs as an isolated process in user space on the host OS. You created a container using docker run which you did using the alpine image that you downloaded. A list of running containers can be seen using the docker ps command.
  • Docker daemon - The background service running on the host that manages building, running and distributing Docker containers.
  • Docker client - The command line tool that allows the user to interact with the Docker daemon.
  • Docker Hub - A registry of Docker images. You can think of the registry as a directory of all available Docker images. You'll be using this later in this tutorial.

Installing Docker

A couple of other things to remember when using the server:

  • Keep in mind that when accessing your containers that serves web-content through a browser, you will need to use the server hostname instead of localhost
  • These servers will be terminated shortly after the end of the academy. So if there is anything on the server you wanna save, please do it on the 4th day.

Log in to your server, and follow the guide on installing docker.

By default, Docker commands will require sudo to run. If this bothers you, look for extra instructions on your distro's installation page to create a docker user group to fix this. We assume that you have made docker non-sudo. If not, then you need to add sudo to every docker command in the examples.

After Docker finishes installing, you should start on the crash-course section below.

crash-course

Your first Docker command

If you haven't already, try running a command with Docker:

docker run hello-world

Your terminal output should look like this:


Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

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

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

This message shows that your installation appears to be working correctly.

Q: So what did this do?

Try to run docker run hello-world again.

Docker has now already downloaded the image locally, and can therefore execute the container straight away.

When Docker is installed on your machine and working properly, proceed to exercise 2.