Difficulty: beginner
Estimated Time: 15-20 minutes

This scenario explains the different aspects of launching a Docker container.

The environment has a Docker installation configured, running on a host called docker.

This scenario has explained how to launch a Docker container. In future scenarios you'll learn more details about Docker, starting with launching your first example application.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Deploying a Docker container - a Primer

Step 1 of 3

Step 1 - Useful commands - Part 1

Hello Docker

To run your first docker container, check your OS architecture first:
~$ uname -m

It should read: x86_64 (~= amd64). This is the traditional Linux arch that was supported by Docker, but they have recently started to support multiple architectures (github.com/docker-library/official-images#architectures-other-than-amd64).

If you're using the wrong architecture/manifest doesn't have this architecture listed, you should see something like this:
no matching manifest for linux/amd64 in the manifest list entries

As such, pulling changed a bit because of manifests.

Pull the docker image locally:
~$ docker pull amd64/hello-world

The image should now be listed:
~$ docker images

Since you have downloaded your image, you can now run it (if you forget to pull, docker run will also do that for you):
~$ docker run amd64/hello-world

The output for the image should appear. To check if the container is running:
~$ docker ps

Nothing is listed, then look for containers that have been closed:
~$ docker ps -a

Useful commands in Docker

Note: Expect common commands like ps, top, exec to appear in similar contexts under Docker.

Search hub.docker.com for a certain image: docker search <name>

Download the image locally (for later use): docker pull <name>

Check configuration json for a specific instance: docker inspect <name>

Check logs for an instance: docker logs <name>

Docker instance control commands

Run a docker container for node image (if it hasn't been found locally, it will automatically pull): docker run -t node

Every time an object gets instantiated, it will be assigned a new id (alphanumeric, 12 characters), and a readable name (name1_name2). Usually you would prefer using the readable name for management.

Start a previously instantiated container (run has been done before, that container is found in docker ps -a): docker run -t hello-world docker start <name>

Connect to a container (attach a bash to the docker instance and login): docker exec -it <name> bash

Stop a currently active container (container is listed in docker ps): docker stop <name>