Common Docker Commands List Every Developer Must Know | Docker Cheatsheet
In this post we will understand very common docker commands that we can use for our day to day development .Docker commands are really helpful and important if your doing any kind of development and using docker for that purpose
What is Docker
Docker is a tool that can package an application and its dependencies in a virtual container that can be run on any Linux server. This helps enable flexibility and portability on where the application can be run, whether on premises, public cloud, private cloud, bare-metal server, etc. Docker containers are built on top of Linux kernel features like namespaces and control groups and are therefore lightweight.
A single Docker container can run on any server, and it makes no difference whether that server is running on your laptop or in a data center. Docker containers are also portable and can be moved from one server to another with all their dependencies intact. This makes it easy to migrate applications to different environments and ensures that the application will always run the same, regardless of the environment. Have a look at our docker cheatsheet .
Docker commands list with examples
- This command helps you know the installed version of the docker software on your system.
2. Pulling Images from Central Docker Registry
docker pull <ImageName>
3. How to get list of docker images downloaded in your system
4. How to Run Containers Based on Image name .
If you have the image available locally it uses that images then it tries to execute and run it else this will throw an error.
$docker container run -itd --name myubuntu ubuntu
ubuntu is the ubuntu image from repository and
myubuntu is the name with which container is running .
5. Docker command to list all the running containers
$docker container ls
6. Docker command to list all the running and stopped containers.
$docker container ls --all
7. How to login to an existing container and execute shell commands
$docker exec -it<containerid> bash $docker exec -it e45deafae85a bash or $docker exec -it e45deafae85a ksh
we can get container id by running above command with ls and depending on type of shell , you can specify ksh or bash .
8. How to stop running docker container.
$docker container stop <ContainerId>
9. Docker Kill and Docker stop difference .
This command kills the container by stopping its execution immediately. The difference
between ‘docker kill’ and ‘docker stop’. ‘docker stop’ gives the container time to shutdown
gracefully, in situations . When it is taking too much time for getting the container to stop, one can opt to kill it .
$docker container kill <Container id>
10. How to remove a container using
$docker rm <container id>