DEV Community

shun
shun

Posted on • Updated on

Basic Docker Commands

Docker is a powerful tool for creating, deploying, and running applications using containerization. Here are some basic Docker commands you might find useful:

Pull an Image

To download an image from Docker Hub or another Docker registry:

docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Enter fullscreen mode Exit fullscreen mode

List Images

To list all available Docker images:

docker images [OPTIONS] [REPOSITORY[:TAG]]
Enter fullscreen mode Exit fullscreen mode

Run a Container

To create a new container and start it:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Enter fullscreen mode Exit fullscreen mode

For example, to run a bash shell with Ubuntu:

docker run -it ubuntu bash
Enter fullscreen mode Exit fullscreen mode

List Running Containers

To list all currently running containers:

docker ps [OPTIONS]
Enter fullscreen mode Exit fullscreen mode

Start a Container

To start a previously created or stopped container:

docker start [OPTIONS] CONTAINER [CONTAINER...]
Enter fullscreen mode Exit fullscreen mode

Stop a Container

To stop a running container:

docker stop [OPTIONS] CONTAINER [CONTAINER...]
Enter fullscreen mode Exit fullscreen mode

Remove a Container

To remove a container:

docker rm [OPTIONS] CONTAINER [CONTAINER...]
Enter fullscreen mode Exit fullscreen mode

Remove an Image

To remove an image:

docker rmi [OPTIONS] IMAGE [IMAGE...]
Enter fullscreen mode Exit fullscreen mode

For more information about these commands and their options, please refer to the official Docker documentation.

Top comments (0)