您现在的位置是:首页 >学无止境 >Docker Cheatsheet网站首页学无止境
Docker Cheatsheet
简介Docker Cheatsheet
The article will be updated from time to time, feel free to check the latest revision: Docker Cheatsheet
Deamon
docker infosystemctl start | stop | restart | status | enable dockerThis command to operate the docker daemon. For more details, you can refer to the systemd.docker system dfquery the disk usage of the docker
images
docker push <username>/<image_name>docker imagesdocker pull | inspect | rmi ubuntu:20.04- normally, the image name is composed by
registry/username/repository:tag, if there is nousername, the default islibrary, which is the official repository. if there is noregistry, the default isdocker.io, which is the official registry.
- normally, the image name is composed by
docker create -it ubuntu:20.04create a container by the imagedocker tag image_name:tag new_image_name:new_tagdocker export/importanddocker save/load:
export/importwill discard history and metadata information, only saving the snapshot state of the container at the timedocker export -o xxx.tar CONTAINERdocker import xxx.tar image_name:tag
save/loadwill save the complete record, with a larger volumedocker save -o xxx.tar image_name:tagdocker load -i xxx.tar
docker hub
docker login -u <username>docker search <image_name>docker push <username>/<image_name>- dangling image: if the image is updated by official, and the tag is allocated to the new image, the old image will be called dangling image. Only display
<none>in thedocker imagescommand.
containers
docker ps -alist all containersdocker pslist running containersdocker statssearch all the containers resource usage (CPU, memory, storage, network)docker rename CONTAINER1 CONTAINER2docker start | stop | restart | rm | top | inspect | kill | port | history CONTAINERdocker run -itd ubuntu:20.04search and run a container (-d means detach) ==pull + create + start- eg.
docker run -p 20000:22 --name my_docker_server -itd docker_images:1.0
- eg.
docker attach CONTAINER⌃ + pand⌃ + qwhich can detach the container⌃+dwhich can close and exit the container(exit; then the container will be stopped)
docker logs -f CONTAINER-f means follow, you can see the logs in real timedocker cp xxx CONTAINER:xxxdocker exec CONTAINER COMMAND- eg
docker exec -it container_name bash docker exec -it container_name /bin/bashif your garrison program issshd(which is not accept input) not thebash, then you should use this command to substitute it. (Recommend, exit; the container will not be stopped)- You can also use
docker run -it container_name /bin/bashspecific the shell to enter the container.
- eg
docker update CONTAINER --memory 500MBdocker container pruneremove all stopped containersdocker commit container_name image_name:tagPackage the container as an image.(Not recommend use to build image, can use as a snapshot of the container)
Docker volume
The volume will not be deleted when the container is deleted. Volume can be shared between containers.
docker volume create VOLUMEcreate a volumedocker run --mount source=VOLUME,target=/webappoption to specify the volume
docker volume lslist all volumesdocker volume rm VOLUMEremove the volumedocker volume pruneremove all unused volumesdocker volume inspect VOLUMEinspect the volumedocker rm -v CONTAINERremove the container and the volume
Besides, you can also mount the host directory to the container. The host directory path must be absolute path.
docker run -d -P
--name web
--mount type=bind,source=/src/webapp,target=/opt/webapp[,readonly]
training/webapp
python app.py
For the detail of build docker image, you can refer to the tips about dockerfile.
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。





U8W/U8W-Mini使用与常见问题解决
QT多线程的5种用法,通过使用线程解决UI主界面的耗时操作代码,防止界面卡死。...
stm32使用HAL库配置串口中断收发数据(保姆级教程)
分享几个国内免费的ChatGPT镜像网址(亲测有效)
Allegro16.6差分等长设置及走线总结