Open a shell (using an application like Terminal or iTerm), and run the following command:

docker run -it ubuntu:16.04 bash

Let's take a look at what this command does.

The docker run command lets you start a container from an image. In this case, you are creating a container from the ubuntu:16.04 image. This is the ubuntu image with the 16.04 tag.

Each Docker container should run a single process. So the docker run command lets you specify a single command to run inside of the container. In our case, we are going to run a bash shell. So we've specified the command to run as bash. Since we are running a bash shell we are going to want to allocate a pseudo-TTY and keep STDIN open. This is why we've added the options -it to the run command.

After running this command you should see something like this:

root@69129699ac86:/#

This is the bash shell running inside of the container you just created from the ubuntu image. You can run ps to see which processes are running in this container.

root@69129699ac86:/# ps PID TTY TIME CMD 1 ? 00:00:00 bash 18 ? 00:00:00 ps

Type exit to close the shell. Now you can run docker ps to see which containers are currently running. You should find that there are no running containers. But if you run docker ps -a you'll see all containers including the one you just stopped. Since the containers are designed to run a single process, once that process is finished the container stops.

Take a look at the fields displayed by docker ps -a. Two important fields are CONTAINER ID and NAMES. If you want to interact with your containers you'll need to know the name or id.

If you want to start this container back up you can do so with docker start -ai <container id> . Since the COMMAND associated with this container is bash we need to attach STDIN, STDOUT, and STDERR, hence the -ai options.