Docker Developer cheat Sheet!!

In this article, you are going to learn the basic docker command and features usage every developer should know, to use efficiently this tool and run your daily mundane task efficiently.

What is Docker?

Docker is a tool that lets you run your applications inside containers. A container is like a virtual machine, but it's much lighter and more efficient.

If you are new to docker then explore my article on docker for begineers.

Basic Docker Commands:

  • docker run <image-name>: This command runs a Docker container based on the specified image.

  • docker ps: This command shows you all the running Docker containers.

  • docker stop <container-id>: This command stops the specified Docker container.

  • docker rm <container-id>: This command removes the specified Docker container.

  • docker images: This command shows you all the Docker images you have downloaded.

  • docker rmi <image-id>: This command removes the specified Docker image.

  • docker pull <image-name>: This command downloads the specified Docker image.

Dockerfile

A Dockerfile is a script that tells Docker how to build your application's image. Here are some basic commands you can use in a Dockerfile:

  • FROM <base-image>: This command sets the base image for your application.

  • RUN <command>: This command runs a command inside the container.

  • WORKDIR <path>: This command sets the working directory for your application.

  • COPY <source> <destination>: This command copies files from your local machine into the container.

  • EXPOSE <port>: This command tells Docker to expose a specific port when running the container.

  • CMD <command>: This command specifies the command to run when the container starts.

Docker Compose

Docker Compose is a tool that lets you define and run multi-container Docker applications. Here are some basic commands you can use with Docker Compose:

  • docker-compose up: This command starts the Docker containers defined in your docker-compose.yml file.

  • docker-compose down: This command stops the Docker containers defined in your docker-compose.yml file.

  • docker-compose logs: This command shows you the logs for the Docker containers defined in your docker-compose.yml file.

  • docker-compose ps: This command shows you the status of the Docker containers defined in your docker-compose.yml file.

Conclusion:

In this article, I talk about the basic command to build a docker image, check logs, remove images, and play with containers and images also discussed if you are working on a combination of more than one docker container and handle that using docker-compose.

I hope this helps, you!!

More such articles:

https://medium.com/techwasti

https://www.youtube.com/channel/UCiTaHm1AYqMS4F4L9zyO7qA

https://www.techwasti.com/

\==========================**=========================

If this article adds any value to you then please clap and comment.

Let’s connect on Stackoverflow, LinkedIn, & Twitter.

Did you find this article valuable?

Support techwasti by becoming a sponsor. Any amount is appreciated!