Search⌘ K
AI Features

Docker CLI: Docker Containers

Explore essential Docker CLI commands to launch and manage containers. Learn how to start, list, access shells, restart, pause, stop, and remove containers, as well as monitor their resource usage. This lesson helps you confidently control containers for effective web development.

Launch a container from an image

To launch the container from an image, docker run or docker container run can be used. The command docker run was available before Docker version 1.13. Version 1.13 introduced docker container command which can be used to run, list, start, etc., the containers. This allows more effective grouping of commands as compared to docker run.

So to start an image as a container instance, we can use the both options as follows:

docker run [options] <image> [command] [args...]
docker container run [options] <image> [command] [args...]

The following command launches a container named mysql (--name), from the latest mysql image in interactive mode (-it shows a terminal log), that exposes port 3306 to the host (-p), stores data in a Docker volume named mysqldata ( ...