Must know Docker commands

Divya P
featurepreneur
Published in
2 min readMay 2, 2021

Learn basic docker commands

When docker is needed?

Developers often face issues while deploying on the server. The app works fine in your system and not the same on the server. Here is what docker plays his rule.

Install docker in your system to get started.

Some must-know commands in docker:

  1. To pull images from docker hub. Dockerhub is the place where you can get all the images.
sudo docker pull <IMAGE_NAME>

2. To List all the running containers:

sudo docker ps

3. To remove all the stopped containers

sudo docker container prune

4. To know the port which the container runs:

sudo docker container port <CONTAINER_ID>

5. To navigate inside the container to see the files:

sudo docker exec -it <CONTAINER_ID> /bin/sh

6. To check the logs of the container:

sudo docker container logs <CONTAINER_ID>

7. To rename a container:

docker container rename <CONTAINER_ID> NEW_NAME

8. To see the history of the image

sudo docker image history <IMAGE_ID>

9. To kill one or more running container

docker kill <CONTAINER_ID>

10. To remove one or more images

docker rmi <IMAGE>

Thanks for reading!

--

--