DEV Community

Cover image for Essential docker commands
Zhalok Rahman
Zhalok Rahman

Posted on

Essential docker commands

1. Showing all containers

docker ps -a

2. Showing running containers

docker ps

3. Showing all images

docker images

4. Showing all conatiner ids

docker ps -a -q

5. Showing all image ids

docker images -q

6. Stopping all containers

docker stop $(docker ps -q)

7. Deleting all containers

docker rm $(docker ps -a -q)

8. Building image from docker file

docker build <directory in which the dockerfile exists>

9. Building image from docker file with a tag name

docker build -t <tag name> <directory in which the dockerfile exists>

10. Running an image in a container

docker run <image_id>
or
docker run <tag name (if provided while building)>

11. Running an image in a container with interactive shell terminal

docker run -i -t <image_id or tag_name> bash

Top comments (0)