In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to check whether docker is working properly". In daily operation, I believe many people have doubts about how to check whether docker is working properly. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to check whether docker is working properly". Next, please follow the editor to study!
# check whether docker is running properly # docker info
Wangande@ubuntu:~$ sudo docker info Containers: 82Images: 37Server Version: 1.9.1Storage Driver: aufs Root Dir: / var/lib/docker/aufs Backing Filesystem: extfs Dirs: 201 Dirperm1 Supported: falseExecution Driver: native-0.2Logging Driver: json-fileKernel Version: 3.13.0-32-genericOperating System: Ubuntu 14.04.1 LTSCPUs: 1Total Memory: 986.8 MiBName: ubuntuID: SZML:DAOQ:6BT5:4QJP:KQSX:NBXL:KBQG:HUF5:CVKQ:LIVI:V55U:24BH
Returns the number of all docker containers and images, the execution driver and storage driver used by docker, and the basic configuration of docker docker is a client-server framework that has a docker program that acts as both a client and a server. As a client, the docker program sends a request to the Docker daemon (such as the request to return information about the daemon itself), and then processes the result of the request
# list image # docker images
Wangande@wangande-MS-7808:~$ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEandrew-site v1.0.0 4e51341b8ec2 4 months ago 628 MBmy v2 f8fc45357f55 4 months ago 504.1 MB
The image is downloaded from the repository, and the image is stored in the repository, which exists in Registry. The default Registry is the Registry service operated by docker, namely docker hub.
The local images are stored in the / var/lib/docker directory of the docker host, and each image is stored under the storage driver used by docker, such as aufs or devicemapper. All containers can be seen in the / var/lib/docker/containers directory.
# pull image # docker pull ${image name}
Docker searches the image repository for related images, and if found, downloads the relevant images
# find docker search # Image ${Image name}
Wangande@ubuntu:~$ sudo docker search ubuntuNAME DESCRIPTION STARS OFFICIAL AUTOMATEDubuntu Ubuntu is a Debian-based Linux operating s... 4629 [OK] ubuntu-upstart Upstart is an event-based replacement for... 66 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 37 [OK] torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 27 [OK] ubuntu-debootstrap debootstrap-variant=minbase-components... 25 [OK] nickistre/ubuntu-lamp LAMP server on Ubuntu 8 [OK] nuagebec/ubuntu Simple always updated Ubuntu docker images... 8 [OK] nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli installed 6 [OK] nimmis/ubuntu This is a docker images different LTS vers... 5 [OK] maxexcloo/ubuntu Base image built on Ubuntu with init, Supe... 2 [OK] darksheer/ubuntu Base Ubuntu Image-- Updated hourly 1 [OK] admiringworm/ubuntu Base ubuntu images based on the official u. 1 [OK] jordi/ubuntu Ubuntu Base Image 1 [OK] datenbetrieb/ubuntu custom flavor of the official ubuntu base. 0 [OK] lynxtp/ubuntu https://github.com/lynxtp/docker-ubuntu 0 [OK] dorapro/ubuntu ubuntu image 0 [OK] webhippie/ubuntu Docker images for ubuntu 0 [OK] croscon/ubuntu Crosconized Ubuntu 0 [OK] life360/ubuntu Ubuntu is a Debian-based Linux operating s... 0 [OK] esycat/ubuntu Ubuntu LTS 0 [OK] widerplan/ubuntu Our basic Ubuntu images. 0 [OK] teamrock/ubuntu TeamRock's Ubuntu image configured with AW... 0 [OK] ustclug/ubuntu ubuntu image for docker with USTC mirror 0 [OK] konstruktoid/ubuntu Ubuntu base image 0 [OK] smartentry/ubuntu ubuntu with smartentry 0 [OK] wangande@ubuntu:~$
Find all ubuntu images on docker hub
Return information
Warehouse name
Mirror description
User rating (Stars)-reflects the popularity of a mirror image
Whether it is official (Official)
Automatic build (Automated)-indicates that the image is automatically built by Docker Hub
# run container # docker run-I-t ${image name}: ${tag} / bin/bash
1. Tell docker to execute the docker run command
2.-I ensure that the STDIN in the container is enabled (the persistence input is half the sky of shell)
3.-t tells the container to assign a pseudo TTY terminal to it (the other half of the shell)
Note: you can use docker help run or man docker run to view the relevant flag parameters
4. Create a container based on andrew-site:v1.0.0 image
5. Docker runs the / bin/bash command in the new container to start a Bash shell
Process:
(1) docker first checks whether an andrew-site:v1.0.0 image exists locally. If there is no such image locally, docker will connect to the Registry to see if the image exists.
(2) once docker finds the image, it will download the image and save it to the local host
(3) then, docker has this image inside the file system to create a new container with its own network, IP address, and a bridging network interface to communicate with the host.
(4) finally, tell docker to run the / bin/bash command in the new container to start a Bash shell
# Container naming docker automatically generates a random name for each container we create. For example, if adoring_hopper wants to specify a name for the container, you can use the-- name flag to do so.
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker run-- name name_test-I-t andrew-site:v1.0.0 / bin/bashroot@6eab7fdaab3e:/andrewSite#
The above command creates a container called name_test, which is legally named with the following characters: lowercase Amurz, uppercase Amurz, digits 0-9, underscores, dots, dashes.
Regular [a-zA-Z0-9 regular. -]
The container must be named uniquely. If we create two containers with the same name, the naming will fail
# restart stopped containers # docker start ${Container name} / ${Container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker start name_testname_test
You can also use # docker restart ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker restart name_testname_test
# attach to the container # docker attach ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker attach name_testroot@6eab7fdaab3e:/andrewSite#
# create a daemon container # docker run-d ${image name}: ${tag}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker run-name daemon_test-d andrew-site:v1.0.0991c0927c9b1cb1fb51e34a1ae0cd364dbbadd47d9a5687c7db7363c5170d777wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES991c0927c9b1 andrew-site:v1.0.0 "/ bin/sh- C 'python / "7 seconds ago Up 6 seconds 80/tcp daemon_test
-d keep the container running in the background (as long as the program cannot exit in the container)
# View the container operation log # docker logs ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker logs daemon_ test [E 160906 07:40:16 services_start:33] current server address: 172.17.0.2 locale:140 80 [I 160906 07:40:16 locale:140] Supported locales: ['en_US',' ja_JP', 'zh_CN']
Docker outputs the last few log entries and returns them, or you can use the-f parameter to monitor docker logs, similar to the tail-f command # docker logs-f ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker logs-f daemon_ test [E 160906 07:40:16 services_start:33] current server address: 172.17.0.2 services_start:33 80 [I 160906 07:40:16 locale:140] Supported locales: ['en_US',' ja_JP', 'zh_CN']
You can also track a segment of the container log by adding-f-- lines after the tail
For example: (1) docker logs-- tail 10-f ${container name} / ${container iD} get the last ten lines of the log
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker logs-- tail 10-f daemon_ test [I 160906 07:40:16 locale:140] Supported locales: ['en_US',' ja_JP', 'zh_CN']
(2) docker logs-- tail 0-f ${Container name} / ${Container iD} track the latest logs of the container
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker logs-- tail 0-f daemon_ test``to make debugging easier, we can also use the-t flag to timestamp each log entry # docker logs-ft ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker logs-ft daemon_test 2016-09-06T07:40:16.712357005Z [E 160906 07:40:16 services_start:33] current server address: 172.17.0.2 06T07:40:16.712357005Z 80 2016-09-06T07:40:16.731046798Z [I 160906 07:40:16 locale:140] Supported locales: ['en_US',' ja_JP', 'zh_CN']
# View the processes in the container # docker top ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker top daemon_test UID PID PPID C STIME TTY TIME CMD root 13815 1508 0 15:40? 00:00:00 / bin/sh-c python / andrewSite/manage.py-- port=80 root 13825 13815 0 15:40? 00:00:00 python / andrewSite/manage.py-- port=80
# run the process inside the container 1. Run the background process inside the container # docker exec-d ${container name} / ${container iD} touch / tmp/new_file
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker exec-d daemon_test touch / tmp/new_file wangande@wangande-MS-7808:~/python-workspace/web-site$
2. Run the interactive command # docker exec-I-t ${container name} / ${container iD} / bin/bash inside the container
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker exec-I-t daemon_test / bin/bash root@991c0927c9b1:/andrewSite#
# stop guarded container # docker stop ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker stop daemon_test daemon_test
Note: the docker stop command sends a SIGTERM signal to the container process. If you want to stop quickly, you can use docker kill to send SIGKILL signal # View Container # docker ps (shows the docker that is running)
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 991c0927c9b1 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 9 minutes ago Up 2 seconds 80/tcp daemon_test
# docker ps-a (shows all docker, including exited)
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 991c0927c9b1 andrew-site:v1.0.0 "/ bin/sh-c'python /" 9 minutes ago Up 18 seconds 80/tcp daemon_test 6eab7fdaab3e andrew-site:v1.0.0 "/ bin/bash" 25 minutes ago Exited (0) 15 minutes ago name_test 1e700c32e95c i71:5000/isee-video-yixun:v4.1.5.30 "/ bin/bash" 10 weeks ago Exited (0) 9 weeks ago desperate_mccarthy 9166129e6105 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 11 weeks ago Exited (137) 11 weeks ago daemon1 229d18a74ec5 andrew-site:v1.0.0 "- d-p 20000 python 80" 11 weeks ago Created daemon 5affe32960c7 andrew-site:v1.0.0 "/ bin/bash" 12 weeks ago Exited (0) 12 weeks ago my_name_test 5dc39a01d48b i71:5000/isee-file "/ bin/bash" 12 weeks ago Exited (0) 12 weeks ago Adoring_hopper c30c288cccc2 i71:5000/isee-file "/ bin/bash" 12 weeks ago Exited (0) 12 weeks ago evil_lichterman 73b7a25539f0 i71:5000/isee-resize "ImageCompress / bin/b" 12 weeks ago Exited (1) 12 weeks ago backstabbing_albattani 04549918fcb4 andrew-site:v1.0.0 "/ bin/bash" 3 months ago Exited (0) 12 weeks ago serene_lalande c89e85466d2f andrew-site:v1.0.0 "/ bin/sh-c 'python /" 3 months ago Exited (1) 3 months ago clever_ Kalam fbe4e3780598 andrew-site:v1.0.0 "/ bin/bash" 3 months ago Exited (130) 3 months ago test-site 0e1a8ff5c52c andrew-site:v1.0.0 "/ bin/bash" 4 months ago Exited (0) 4 months ago big_dijkstra da0b188806a8 andrew-site:v1.0.0 "/ bin/bash" 4 months ago Exited 4 months ago jovial_lamarr 98d97845c3d7 i71:5000/isee-sms-yixun:v4.1.4.55 "/ bin/sh-c 'python /" 4 months ago Exited 4 months ago stoic_rosalind 7b6b75db6d8d andrew-site:v1.0.0 "/ bin/sh-c 'python /" 4 months ago Exited (137) 4 months ago elated_pasteur 6a3ee17b8f5b andrew-site:v1.0.0 "/ bin/sh-c' python /" 4 months ago Created goofy_thompson 98d6fec1de29 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 4 months ago Created nostalgic_swanson c96bce8edcae andrew-site:v1.0.0 "/ bin/sh-c' python / "4 months ago Created gloomy_goldberg edbb85621f6e andrew-site:v1.0.0" / bin/sh-c 'python / "4 months ago Created stupefied_heisenberg 314d7a7d7fac andrew-site:v1.0.0" / bin/sh-c' python / "4 months ago Exited (137) 4 months ago serene_pike 27cb093780b1 andrew-site:v1.0.0" / bin/sh-c'p
# docker ps-l (shows the last one)
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker ps-l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 991c0927c9b1 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 9 minutes ago Up 39 seconds 80/tcp daemon_test
# docker ps-n x (show the last x containers)
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker ps-n 5 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 991c0927c9b1 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 10 minutes ago Up About a minute 80/tcp daemon_test 6eab7fdaab3e andrew-site:v1.0.0 "/ bin/bash" 26 minutes ago Exited (0) 16 minutes ago name_test 1e700c32e95c i71:5000/isee-video-yixun:v4.1.5.30 "/ bin/bash" 10 weeks Ago Exited (0) 9 weeks ago desperate_mccarthy 9166129e6105 andrew-site:v1.0.0 "/ bin/sh-c 'python /" 11 weeks ago Exited (137) 11 weeks ago daemon1 229d18a74ec5 andrew-site:v1.0.0 "- d-p 20000 python 80" 11 weeks ago Created daemon wangande@wangande-MS-7808:~/python-workspace/web-site$
# automatic restart docker causes the container to stop running due to some error. You can use the-- restart flag to let docker restart automatically. -- the restart flag checks the exit code of the container and decides whether to restart the container. The default docker does not restart the container.
Sudo docker run-restart=always-name daemon_test andrew-site:v1.0.0
-- restart is set to always, no matter what the exit code is, it will restart. You can also set the flag to on-failure so that when the container exit code is non-zero, on-failure will automatically restart. You can also accept optional restart times, such as:-- restart=on-failure:5#### in addition to docker ps, you can also get more container information through docker inspect # docker inspect ${container name} / ${container iD}.
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker inspect daemon_test [{"Id": "991c0927c9b1cb1fb51e34a1ae0cd364dbbadd47d9a5687c7db7363c5170d777", "Created": "2016-09-06T07:40:16.363206933Z", "Path": "/ bin/sh", "Args": ["- c", "python / andrewSite/manage.py-- port=80"], "State": {"Status": "running", "Running": true, "Paused": false "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 14068, "ExitCode": 0, "Error": "", "StartedAt": "2016-09-06T07:49:33.647550223Z", "FinishedAt": "2016-09-06T07:48:47.666181288Z"}, "Image": "4e51341b8ec2db42cf656162884972c58f07ea29cdcbda10696db11984c65191". }]
Select-f or-- format to view the result # docker inspect-fallow'{{.State.Running}}'${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker inspect-fallow'{{.State.Running}} 'daemon_test true
Return the running status of the container # docker inspect-- format'{{State.Running}}'${Container name} / ${Container iD} ${Container name} / ${Container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker inspect-- format'{{.Name}} {{.State.Running}} 'daemon_test name_test / daemon_test true / name_test false
Specify multiple containers at the same time, and display the output of each container # delete containers if the containers are not in use, we can use the docker rm command to delete them # docker rm ${container name} / ${container iD}
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker rm 9166129e6105 9166129e6105
Note: the running container cannot be deleted. You must use the docker stop or docker kill command to stop the container.
Wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker rm 991c0927c9b1 Error response from daemon: Conflict, You cannot remove a running container. Stop the container before attempting removal or use-f Error: failed to remove containers: [991c0927c9b1] wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker stop 991c0927c9b1 991c0927c9b1 wangande@wangande-MS-7808:~/python-workspace/web-site$ wangande@wangande-MS-7808:~/python-workspace/web-site$ wangande@wangande-MS-7808:~/python-workspace/web-site$ sudo docker rm 991c0927c9b1 991c0927c9b1
There is currently no command to delete all containers at once, but you can delete them with the following code
Sudo docker rm docker ps-a-Q
-a lists all containers-Q means that only the ID of the container is returned and no other information about the container is returned, so that we can get the list of containers and pass them to the docker rm command to delete all containers. This is the end of the study on "how to check whether docker is working properly". Hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.