Breaking News

Docker Cheatsheet for Beginners

Docker Cheatsheet for Beginners

Docker CheatSheet for Beginners

Imagine you are working on a critical project, it’s almost complete and you ask your manager to have a look at the status. He goes through the project and a few days later come up to you asking to accommodate some last minute changes and updates. This request itself sounds like a nightmare for any software developer and can give sleepless nights to many. Now you are thinking of all the components you need to install and update like the OS,dependencies, version you used previously on the server, several packages that are required, etc. The process is quite tedious and requires keeping several factors to keep in mind.

To help you overcome such situations, Docker comes to your rescue.

What is Docker?

Docker is a platform that helps in building a container for the applications. A container packages the code in such a way that all the application dependencies are easily managed and are taken care of. This helps in running the applications on any machine irrespective of the server infrastructure. We can run the same code on a Linux server or a Windows without much hassle.

How does Docker works?

In the above scenario to make our job easy, we can create a Docker container in the machine. We can have many Docker images inside a container; the image contains several parameters related to set java path, Ubuntu, apache version, etc. These parameters might be specific for an application but we can create multiple docker images inside a container. There might be another application that requires a  similar configuration but with slight differences. In such cases docker comes very handily we can create the image from any existing docker images that can slightly modify some parameters as per requirement.

Setting up Docker locally on the machine

Download Docker from here once the setup is done, follow these steps. Like discussed above Docker creates images which can be reused later as and when required. ‘libcontainer’ is used to create docker container.

  • To create a Docker container, download the ‘hello world’ image, use the command–

$ docker run hello world

  • For checking the number of images on your system, use this command –

$ docker images

These are some of the basic commands to setup the docker container. Now in this post we are trying to share a list of docker commands which may come in handy for beginners.

List of Common Docker commands

$ docker run                                          This command is used to run a command in a new container.

$ docker start                                        This command is used to start one or more stopped containers.

$ docker stop                                         This command is used to stop one or more running containers.

$ docker build                                       This command is used to build an image form a Docker file.

$ docker push                                        This command is used push an image or a repository to a registry.

$ docker pull                                          This command is used pull an image or a repository from a registry.

$ docker export                                     This command is used export a container’s file system as a tar archive

$ docker exec                                         This command is used  to run a command in a run-time container

$ docker search                                    This command is used to search  the Docker Hub for images

$ docker attach                                     This command is used attach  to a running container

$ docker commit                                 This command is used create  a new image from a container’s changes

$ docker –version                               This command is used to extract docker version information.

$ docker ps                                             This command is used to fetch all the running containers. 

$ docker kill                                           This command forcefully terminates the container execution.

$ docker cp                                             This command is used to copy files/folders between a container and the local machine.

$ docker  events                                    This command is used to fetch the real time events from the server.

$ docker plugin                                    This command is used to manage the Plugins.

$ docker rename                                 This command is used to rename a container.

$ docker container                             This command is used to manage the containers.

$ docker history.                                This command is used to show the history of an image.

$ docker restart                                  This command is used to restart one or more containers.

$ docker rm                                            This command is used to remove one or more docker containers.

$ docker rmi                                          This command is used to remove one or more images.

$ docker login                                       This command is used to log in to a Docker registry.

$ docker logout                                    This command is used to  log out from a Docker registry.

$ docker logs                                          This command is used to  fetch the logs of a container.

$ docker config                                     This command is used to manage Docker configuration.

Vinkmag ad

Akshaya Kolay

Read Previous

MLOps: When DevOps meets Data Science

Read Next

DevOps 2021: Paving your way into SRE

Leave a Reply

Your email address will not be published. Required fields are marked *