Explanation of the Docker commands cheat sheet

Explanation of the Docker commands cheat sheet
Techiio-author
Written by Nilima PaulFebruary 19, 2022
11 min read
Docker
6 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 6 VIEWS SHARE
Techiio-author
Nilima Paul

Technology Security Analyst

In this article we will know , about the Docker commands cheat sheet.

Introduction of Docker commands cheat sheet:

The accompanying article gives a layout to Docker commands cheat sheet with DevOps assuming control over all the product business, there is a requirement for devices that can do movements of every kind in the product advancement life cycle together. Docker is an apparatus intended to make, send and show various applications to utilizing holders. These compartments assist the engineer to make bundles for an application with every one of the parts that are required in the program. These can be various libraries and different conditions and boat it out to the bundle. It goes about as a virtual machine. It permits the applications to involve the very Linux portion as the framework that they are running and requires just the applications that are to be delivered and things that are not previously running on the PC.

Basics of Docker commands cheat sheet:

Following are some basics of Docker commands cheat sheets:

1. Docker version

This command will show you the currently installed version:

Code:

docker version

2. Docker help

This cheat sheet Docker command provides the entire list of commands that the client understands. Most of the commands present here are used to deal with the containers.

Code:

docker --help

3. Docker start

This command lets the user start a particular container.

code :

$ docker start [OPTIONS] CONTAINER [CONTAINER...]

4. Docker ps

This command helps to getting all running containers as well as the containers that are exited from.

Code:

docker ps -a

5. Docker exec -ti [container] [command]

This Docker commands cheat sheet can be used to run any shell command inside any particular container.

Code:

docker exec -ti [container] [command]

6. Docker run -ti –rm –image

This Cheat Sheet Docker command does the work of creating and starting a container at the same time. It can also run the command in it and, in the end, remove the container after executing this command.

Code:

docker run --rm Nginx Nginx -h

7. Docker inspect

This cheat sheet Docker command is useful in getting displayed the low-level information of any particular Docker object.

Code:

docker inspect Microsoft/dynamics-nav:dev preview

8. Docker kill

This command is used to kill the container by stopping the execution of the container. Its kill is different from ‘docker stop’. The ‘docker stop’ gives the container time to shut down properly, and in such situations, it takes longer to stop. The kill command, on the other hand, stops the process immediately.

Code:

docker kill fc5e91dfe6f6

9. Docker commit

This command helps in creating a new image of any edited container that is already existing on the container.

code :

$ docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

10. Docker login

If a user wants to log in to the Docker repository, then the user must make use of this command.

Code:

docker login docker.viurdata.com

Intermediate Docker commands cheat sheet:

Below commands can be used on an intermediate level by any user.

1. Docker push

This command can be used to push an image to the docker hub repository.

code:

Docker push <username/image name>

2. Docker images

This command lists all images that are stored locally on a computer. It also lists all images, including all intermediate images on the terminal.

code:

$ docker images [OPTIONS] [REPOSITORY[:TAG]]

3. Docker build

By using this command, a Docker image is built from a Docker file. The time at the end of the command specifies the context, which is built using the Docker image. Also, if the file does not reside in the same folder where the command is being run, the user needs to add the ‘-F flag to specify the folder where the file resides.

code:

docker build [OPTIONS] PATH | URL | -

4. Docker pulls

This command can be used to pull an image from the docker registry to your computer. Also, a specific version of an image can be pulled.

code:

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

5. Docker tag

This helps in tagging the image with any tag that helps the registry that will be used instead of the one that was used locally. This tag can be the same as the local tag.

code:

docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

6. Docker rm $(docker ps -a -q)

This command is useful when a user deletes all containers that are currently not in a running state. By hitting this command, all unnecessary containers will be deleted.

code:

docker rm [OPTIONS] CONTAINER [CONTAINER...]

7. Docker rmi

This command is useful when the user wants to delete an image from the local image store.

code:

docker rmi [OPTIONS] IMAGE [IMAGE...]

8. Docker ps

To get a list of all containers that are currently running, the user can use this command and get a complete list.

code:

docker ps [OPTIONS]

9. Docker-machine env default

If the user wants to configure the environment variables, then this command will come to your rescue. ‘default’ here suggests that without any additional complexity, this command should run and set the command line variables. As a developer, you can also list the available machines with the Docker-machine ls command and start or stop any particular machines.

code:

(eval $(docker-machine env default))
Advanced Docker commands cheat sheet:

Below are some advanced Docker commands cheat sheets:

1. Using multiple Docker compose files

These cheat sheet Docker commands utilize different Docker records; an engineer should change the application with its surroundings, organizing, and creation. The Docker compose order helps in taking this forward as it as of now peruses two documents as a matter of course.

Code:

$ docker-compose up -f my-override-1.yml my-override-2.yml

Developer can use the –f option to Docker-compose up to use multiple files.

2. Using ONBUILD Commands in Images

This onbuild order indicates various orders which are to be run when another picture is being worked from the picture that is being utilized. It tends to be considered an idea of legacy.

code:

ONBUILD COPY package.json /app
Tips and Tricks for Docker Commands Cheat Sheet:

Below, tricks on Commands cheat sheet can help you save a lot of time.

1. Tailing logs

To quickly have a look at logs, the below command can be used.

Code:

sudo docker logs -t-tail 1000 my_postgres 2>&1 | grep -I error

2. Copy and paste files

Docker enables you to copy and paste files into a container. It can be done from host to container and vice versa.

Code:

COPY script.sh /tmp
ADD script.sh /tmp

3. Stop all containers

All containers can be stopped by using the below command.

Code:

docker stop $(docker ps -q)

It will stop run only for active.

Code:

docker stop $(docker ps -aq)

It will stop run for all.

Conclusion:

Docker is a guardian angel in the DevOps working climate with its various offices, it is probably the best apparatus that can be utilized to send various undertakings. It is the best stage to create, boat, and run various applications together.

Docker
docker command
cheat sheet
devops
6 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 6 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance