Вы находитесь на странице: 1из 3

Docker Commands

There are several Commands that Docker CLI enables a user to use which customize Docker images. Some of
them are:
1. Docker history:
Shows the history of an image, which also includes changes made to it and its layers.
$ docker history [OPTIONS] IMAGE
2. Docker update:
This command permits a user to update the configuration of containers.
$ docker update [OPTIONS] CONTAINER [CONTAINER...]
3. Docker tag
It creates a tag, like as target_image, that enables users to group as well as organize container images.
$ docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
4. Docker search
This command looks in Docker Hub, an image repository, for whatever the user needs.
$ docker search [OPTIONS] TERM
5. Docker save
It permits a user to save images to an archive.
$ docker save [OPTIONS] IMAGE [IMAGE...]
6. Docker rmi
It removes one or multiple images.
$ docker rmi [OPTIONS] IMAGE [IMAGE...]
7. Docker image
It simply manages images
$ docker image COMMAND
8. Docker image build
This command builds an image from a Dockerfile
$ docker image build [OPTIONS] PATH | URL |
9. Docker inspect
In order to see the details of an image or container, we use it.
$ docker inspect Repository
10. Displaying Docker Images
We can issue the following command, in order to see the list of images on the system.
$ docker images
11. Downloading Docker Images
By using the Docker run command, we can download Images from Docker Hub.
$ docker run image
12. Docker images -q
This command helps to return only the Image ids of the images.
$ docker images
13. To test your new image, type
$ docker run centos:centos7 /bin/ping  opera.com -c 5
14. List Docker Containers
$ docker ps -a
15. Checking Docker Networking
$ docker network ls
$ docker network inspect [network Name]
16. Check Resource Consumption by Running Container#
$ docker stats
17. Setting Resource limits for a docker container
$ docker run -it -c 256 -m 300M centos:centos7 /bin/bash
18. Stop/Start/Restart operations for docker container
$ docker start [container ID]     ## to start a docker container
$ docker stop [container ID]      ## to stop a docker container
$ docker restart [container ID]   ## to restart a docker container
19. Committing the Docker Container Updates (This command turns your container to an image)
$ docker commit [container ID]
20. Adding a Repository/Tag value to a image
$ docker tag [image ID] <repo : tags >
21. Removing / Deleting a container
$ docker rm [container ID]
22. Checking the docker container Logs
$ docker logs [container_id ]
23. Let’s create our container and host a demo website quickly using Python SimpleHTTPServer module
which will listen on port 8080.
$ mkdir -p /var/www/html
$ echo “This is my Yogesh’s Test Docker Website” >
/var/www/html/demowebpage.txt
$ docker run -d -p 8080:8080 –name=”python_web” -v
/usr/sbin:/usr/sbin -v /usr/bin:/usr/bin

v /usr/lib64:/usr/lib64 -w /var/www/html -v
/var/www/html:/var/www/html centos:centos7

/bin/python -m SimpleHTTPServer 8080


-d, –detach       ## Run container in background and print container ID
-p, –publish value ## Publish a container’s port(s) to the host (default [])
-v, –volume value    ## Bind mount a volume (default [])
-w, —workdir string  ## Working directory inside the container
24. Check the Network Ports Allocation
$ netstat -tupln | grep 8080
25. Lets test the Website
$ curl localhost:8080/demowebpage.txt

Docker Container Command


26. Docker Top: We can see the top processes within a container by using the below command.
$ docker top ContainerID
27. Docker stop: In order to stop a running container.
$ docker stop ContainerID
28. Docker rm: To delete a container.
$ docker rm ContainerID
29. Docker stats: To offer the statistics of a running container.
$ docker stats ContainerID
30. Docker attach: In order to attach to a running container.
$ docker attach ContainerID
31. Docker pause: To pause the processes in a running container.
$ docker pause ContainerID
32. Docker unpause: To unpause the processes in a running container.
$ docker unpause ContainerID
33. Docker kill: To kill the processes in a running container.
$ docker kill ContainerID

Вам также может понравиться