A docker run
command is one of the basic commands in a Docker universe as it is used to start containers from Docker images.
In this short note i will show how to start a Docker container in a foreground, in a background or with an interactive shell session of bash
or sh
from the command line using the docker run
command.
Cool Tip: How to run a Docker image as a container! Read More →
Start Docker Container
Docker Image: If the image from which you want to start a Docker container using the docker run
command is not downloaded yet (not in cache), it will be pulled automatically from a Docker registry.
Start a container from a Docker image in a foreground:
$ docker run <image> $ docker run <image>:<tag> $ docker run <registry>:<port>/<repository>/<image>:<tag>
Start a Docker container in a background:
$ docker run -d <image>
Start a Docker container with an interactive shell session of bash
or sh
:
$ docker run -it <image> /bin/bash - or - docker run -it <image> /bin/sh
Cool Tip: How to install a Docker Compose! Read More →