In this section we are going to do a basic introduction into the use of Docker. To follow along Install Docker on Windows or go to http://play-with-docker.com/ where no installation is required. You can also run all these commands on a remote machine by adding -H {IP Address} eg -H 192.162.0.5 As you go through this series of tuts take a look at the official Docker Docs for details as you need.

First make sure Docker is Running (See Install Docker on Windows). Then open the Command Prompt and type the following commands.

Confim the version

> docker -v

Response:

Docker version 18.03.1-ce, build 9ee9f40

We will go into the details on how to build and run containers at a later stage but for now lets run a hello world app from the Docker registry.

> docker run hello-world

Response:

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

9db2ca6ccae0: Pull complete

Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc

Status: Downloaded newer image for hello-world:latest

The above response is the process of finding the requested contained and running.

The application starts to run and prints out to the console, take a read through what the hello world app prints as it provides some valuable information:

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.(amd64)

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://hub.docker.com/

 

For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/

Try running docker run hello-world again and you will see that it does not download it again because it already has it locally.

Add parameters on run

Some Docker Images require parameters. eg nginx

> docker run -p 8080:80 -d nginx

At a later stage we will cover different parameters and what they do.

Once the Image has been pulled and started visit http://localhost:8080/ and you should get a "Welcome to nginx!" page

Check out these links for more info:

My Docker Samples