Chapter 3. First Steps
This chapter will guide you through your first steps with using Docker. We start by launching and using some simple containers to give you a feel for how Docker works. Then we move onto Dockerfiles—the basic building block of Docker containers—and Docker Registries, which support the distribution of containers. The chapter concludes with a look at how to use a container to host a key-value store with persistent storage.
Running Your First Image
To test that Docker is installed correctly, try running:
$ docker run debian echo "Hello World"
This may take a little while, depending on your Internet connection, but eventually you will get something similar to the following:
Unable to find image 'debian' locally debian:latest: The image you are pulling has been verified 511136ea3c5a: Pull complete 638fd9704285: Pull complete 61f7f4f722fb: Pull complete Status: Downloaded newer image for debian:latest Hello World
So what’s happened here? We’ve called the docker run
command, which is
responsible for launching containers. The argument debian
is the name of the
image1 we want to use—in this
case, a stripped-down version of the Debian Linux distribution. The first line of
the output tells us we don’t have a local copy of the Debian image. Docker
then checks online at the Docker Hub and downloads the newest version of the
Debian image. Once the image has been downloaded, Docker turns the image into a
running container and executes the command we specified—echo "Hello ...
Get Using Docker now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.