28
MarTop Docker Commands You Should Know
Docker is a modern containerization platform that enables developers to build, ship, and run applications in isolated environments. Docker simplifies application deployment by packaging everything needed to run an application, ensuring consistency across different environments. Big companies rely on Docker for its efficiency, scalability, and seamless integration with CI/CD pipelines.
Hence, in this Docker Commands Guide, we will explore essential Docker commands, how they work, and their role in managing containers effectively.
What is Docker?
Docker is an open-source platform that helps developers build, package, and deploy applications using containers. Containers are lightweight, portable, and ensure applications run consistently across different environments. Docker eliminates compatibility issues by packaging applications with their dependencies. Docker simplifies deployment and is widely used in DevOps, cloud computing, and CI/CD pipelines.
Read More: Free Docker Online Course with Certificate - Beginner Level |
What does Docker do?
Docker helps you build, package, and run applications using containers. Docker makes sure your apps work the same way everywhere by including everything they need to run. With Docker, you can deploy faster, use resources better, and scale easily, making it a great tool for DevOps, microservices, and cloud computing.
Docker Commands
1. docker --version
- This command is used to check the installed Docker version.
- It helps verify if Docker is correctly installed on the system.
- It displays the version of the Docker client installed on the machine.
- Useful for troubleshooting compatibility issues with Docker images or commands.
2. docker pull
- This command is used to download a Docker image from a registry like Docker Hub.
- It ensures you have the latest or specified version of an image.
- It supports pulling multiple architectures based on the host system.
- Useful for setting up new environments quickly without manual downloads.
3. docker run
- This command is used to create and start a new container from a specified image.
- It allows passing environment variables, ports, and configurations during execution.
- Supports detached mode (`-d`) for background execution.
- Can automatically remove the container after execution using `--rm`.
4. docker ps
- This command is used to list all running Docker containers.
- It shows container IDs, names, statuses, and other details.
- Supports filtering with `--filter` to list specific containers.
- Using `--format` allows custom output for scripting purposes.
5. docker ps -a
- This command is used to list all Docker containers, including stopped ones.
- It helps track container history and troubleshoot stopped instances.
- Provides timestamps for when containers were created and exited.
- Supports sorting containers using `--sort`.
6. docker exec
- This command is used to run commands inside an already running container.
- It is useful for debugging or interacting with containerized applications.
- Allows running interactive sessions using `-it`.
- Supports executing scripts and commands without opening a shell.
7. docker stop
- This command is used to stop a running container gracefully.
- It allows the container to exit safely before termination.
- Ensures application shutdown processes are executed.
- Can accept multiple container IDs or names at once.
8. docker kill
- This command is used to forcefully stop a running container.
- It immediately terminates the container without a graceful shutdown.
- Supports sending specific signals to a container using `--signal`.
- Useful for emergency container shutdowns.
9. docker commit
- This command is used to create a new image from an existing container.
- It captures the container's current state as a reusable image.
- Allows adding commit messages for better tracking.
- Supports changing metadata such as environment variables during commit.
10. docker login
- This command is used to authenticate a user with a Docker registry.
- It is required before pushing images to a private or public registry.
- Stores credentials securely for future use.
- Supports logging into self-hosted Docker registries.
11. docker push
- This command is used to upload a Docker image to a registry.
- It allows sharing images with teams or deploying to cloud environments.
- Requires authentication before pushing to a private registry.
- Supports pushing multiple tags of an image at once.
12. docker images
- This command is used to list all locally available Docker images.
- It displays image IDs, tags, sizes, and creation dates.
- Supports filtering by repository or tag.
- Shows dangling images that might need cleanup.
13. docker rm
- This command is used to remove one or more stopped containers.
- It helps free up system resources by deleting unused containers.
- Supports force removal with `-f`.
- Can remove multiple containers at once using space-separated IDs.
14. docker rmi
- This command is used to remove one or more Docker images.
- It clears up disk space by deleting unused or old images.
- Requires removing associated containers before deleting an image.
- Supports force deletion with `--force`.
15. docker build
- This command is used to create a new Docker image from a Dockerfile.
- It automates the process of defining and packaging containerized applications.
- Supports multi-stage builds for optimizing image size.
- Can specify a custom Dockerfile using `-f`.
32. docker system df
- This command is used to show disk space usage by Docker images, containers, and volumes.
- It helps analyze storage consumption and optimize resource management.
- Supports identifying unused Docker resources.
- Helps free up space using `docker system prune`.
Conclusion
Docker's command-line interface (CLI) provides a powerful and flexible way to interact with containers, making it easier to ensure consistency across development, testing, and production environments. By mastering these commands, developers can leverage Docker's full potential to improve scalability, portability, and efficiency in modern software development workflows. If you want to master Docker just go for Docker and Kubernetes Certification Training.FAQs
- is lists the resources.
- cp copies files/folders between the container and the local file system.
- create creates a new container.
- diff inspects changes to files or directories in a running container.
- logs fetches the logs of a container
What Docker is used for
- Rapid application development: Docker helps developers build and test applications faster.
- Application portability: Docker containers can run consistently across different environments, including on different servers.
- Application isolation: Docker containers provide an isolated environment for each application, which can help improve security and manageability
Take our Docker skill challenge to evaluate yourself!

In less than 5 minutes, with our skill challenge, you can identify your knowledge gaps and strengths in a given skill.