# Docker Essentials: An Introduction and Key Commands 🐳

### **What is Docker**

Docker is a tool that helps you build, share, and run applications using containers. A container is a small package that includes everything an application needs to work, like code, libraries, and tools. This makes it easy to move applications from one place to another.

**Why is Docker Important?**

Using Docker is important because it makes the development and deployment processes easier. It ensures that applications run the same way in different places, whether on a developer's laptop, in testing, or in production. This consistency helps reduce problems, improve teamwork, and make work more efficient, which is especially helpful in DevOps.

**Introduction to Docker Commands**

In this blog, we will give an overview of essential Docker commands. This is just a starting point, and future blogs will go into more detail about each command. Whether you are new to Docker or want to learn more, this guide will help you understand the commands you need for your work.

Here’s a quick overview of some important Docker commands you should know:

1. **Docker Version**  
    This command shows you the version of Docker you have installed on your machine. It's useful for checking if you are using the latest version.  
    **Command:** <mark>docker version</mark>
    
2. **Docker Search**  
    This command lets you search for images on Docker Hub. You can find available images to use in your projects.  
    **Command:** <mark>docker search &lt;image_name&gt;</mark>
    
3. **Docker Pull**  
    Use this command to download an image from Docker Hub to your local machine. This is how you get images to run.  
    **Command:** <mark>docker pull &lt;image_name&gt;</mark>
    
4. **Docker Run**  
    This command creates and starts a new container from an image. It’s one of the most commonly used commands in Docker.  
    **Command:** <mark>docker run &lt;image_name&gt;</mark>
    
5. **Docker PS**  
    The <mark>docker ps</mark> command lists all currently running containers. You can see important details about each one.  
    **Command:** <mark>docker ps</mark>
    
6. **Docker Stop**  
    This command stops a running container. It allows you to safely shut down a container without losing any data.  
    **Command:** <mark>docker stop &lt;container_id&gt;</mark>
    
7. **Docker Restart**  
    Use this command to restart a stopped container. It will stop the container and then start it again.  
    **Command:** <mark>docker restart &lt;container_id&gt;</mark>
    
8. **Docker Kill**  
    This command forcefully stops a running container. It's a quick way to shut down a container if it’s not responding.  
    **Command:** <mark>docker kill &lt;container_id&gt;</mark>
    
9. **Docker Exec**  
    With this command, you can run a command inside a running container. It’s useful for accessing a shell or running scripts.  
    **Command:** <mark>docker exec -it &lt;container_id&gt; &lt;command&gt;</mark>
    
10. **Docker Login**  
    Use this command to log into Docker Hub so you can push and pull images from your account.  
    **Command:** <mark>docker login</mark>
    
11. **Docker Commit**  
    This command creates a new image from changes made in a container. It saves the current state of a container as a new image.  
    **Command:** <mark>docker commit &lt;container_id&gt; &lt;new_image_name&gt;</mark>
    
12. **Docker Push**  
    Use this command to upload your local image to Docker Hub. This allows you to share your images with others.  
    **Command:** <mark>docker push &lt;image_name&gt;</mark>
    
13. **Docker Network**  
    This command lets you manage Docker networks. You can create, inspect, and remove networks to connect your containers.  
    **Command:** <mark>docker network &lt;command&gt;</mark>
    
14. **Docker History**  
    The <mark>docker history</mark> command shows the history of an image, including all the layers that make it up. This helps you understand how the image was built.  
    **Command:** <mark>docker history &lt;image_name&gt;</mark>
    
15. **Docker RMI**  
    Use this command to remove an image from your local system. This helps you free up space when you no longer need an image.  
    **Command:** <mark>docker rmi &lt;image_name&gt;</mark>
    
16. **Docker PS -a**  
    This command lists all containers, including those that are stopped. It gives you a complete view of all containers on your system.  
    **Command:** <mark>docker ps -a</mark>
    
17. **Docker Copy**  
    The <mark>docker cp</mark> command copies files between your local filesystem and a container. This is useful for transferring data.  
    **Command:** <mark>docker cp &lt;container_id&gt;:&lt;path&gt; &lt;local_path&gt;</mark>
    
18. **Docker Logs**  
    Use this command to view the logs of a container. It helps you troubleshoot issues by showing you the output and errors.  
    **Command:** <mark>docker logs &lt;container_id&gt;</mark>
    
19. **Docker Volume**  
    This command manages data volumes in Docker, which are used to store data persistently. Volumes help keep data safe even if containers are deleted.  
    **Command:** <mark>docker volume &lt;command&gt;</mark>
    
20. **Docker Logout**  
    Use this command to log out from Docker Hub. It’s a good practice for security when you’re done working.  
    **Command:** <mark>docker logout</mark>
    

### Conclusion

These important Docker commands give you a good start for managing your containers and images in your DevOps journey. Knowing these basics will help you use Docker with confidence. In the upcoming blog posts, we will look closely at each command, explaining how they work and how to use them best. This will help you understand Docker better and make your work in DevOps easier.

Thank you for being part of this Docker journey, and happy learning 😎
