Docker Tutorial – Running Your First Image

install docker on debian 8

Hello everyone, welcome to Docker Tutorial. Today, we are going to continue our Docker learning. We will show you some basic Docker operations. If you accidentally arrived at this page, you may want to check out our previous post: The differences between Containers vs Virtual Machines

What will you learn?

  • Create or run your first containers
  • Pull docker image from the DockerHub
  • Learn some basic Docker commands

Run Your First Docker Image

After you have installed Docker, you may want to test if it runs properly. So let’s jump into our first step to run your first image. Execute this command on Terminal. Make sure you are connected to the internet.

sudo docker run debian echo "Hello"


dhani@dhani-ThinkPad-T420:~$ sudo docker run debian echo "hello"
Unable to find image 'debian:latest' locally
latest: Pulling from library/debian
55cbf04beb70: Pull complete 
Digest: sha256:f1f61086ea01a72b30c7287adee8c929e569853de03b7c462a8ac75e0d0224c4
Status: Downloaded newer image for debian:latest

The “docker run” command will launch a docker container. The term debian here refers to the Debian Linux distribution. Basically, the command will create and run a new container which is based on Debian Linux. Since we don’t have any local copy of the Debian image, the command will download or pull from DockerHub. And it will download the latest version available there.

Display Running Containers

Once the command finish downloads the Debian image, Docker turns the image into a running container and then execute our “echo” command to display “Hello”. Docker will delete the container after the commands are completely executed. Let’s check.

sudo docker ps


As you can see, the container we just created with Debian image is not running anymore. Now try using this command to list any containers (active and not active).

sudo docker ps -a


As you can see, there is a container which is based on the Debian image with status Exited.

Display Docker Images

We can easily list or display the local copy of Docker Images with this command

sudo docker images


Run a Container with Interactive Session

On this section, we are going to run a new container with a tty interactive session. 

sudo docker run -i -t debian /bin/bash

Please note the -i and -t flags. These flags tellDocker to run a container based on Debian image with interactive bash shell. This container will remain active until we execute the exit command. 



Be the first to comment

Leave a Reply