How to Run a Docker Image as a Container?

Better Stack Team
Updated on August 1, 2022

Docker runs processes in isolated containers. A container is a process that runs on a host. The host may be local or remote. When an operator executes docker run, the container process that runs is isolated in that it has its own file system, its own networking, and its own isolated process tree separate from the host.

The specific way to run it depends on whether you gave the image a tag or name.

To see if your docker image has a name, list the images using the docker images command and look for the tag or repository column:

docker images
REPOSITORY          TAG                 ID                  CREATED             SIZE
ubuntu              12.04               8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)

To run a Docker image with a name, use the following syntax:

docker run -i -t ubuntu:12.04 /bin/bash

To run a Docker image with the image id, use the following syntax

docker run -i -t 8dbd9e392a96 /bin/bash
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →