Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Skills of using docker

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

01. Install Dockercurl-sSL https://get.docker.com/ | shcentos6 epelyum install-y docker-iocentos 7yum install-y docker-engineservice docker startservice docker stopservice docker restart02. View Docker information docker info file location / var/lib/docker03. Find https://hub.docker.com/docker search centos (image name)-- automated automation option-- no-trunc shows 25 results with full ID-s minimum star 04. View the 3-star mirror docker search-s 3 centos 05. Pull image docker pull: docker pull centos-an all image docker daemon startup parameters "--insecure-registry=0.0.0.0/0" 06. Modify / etc/default/dockerDOCKER_OPTS= "--REGISTRY-MIRROR= https://www.daocloud.io"docker daemon startup parameters"-- insecure-registry=0.0.0.0/0 "07. List mirrors docker images-a shows all mirrors-f filter conditions-no-trunc shows full ID-Q unique ID08. Use run to create container docker run docker run-dti-p 80:80-v / root/data:/data hello:1.0-- name hello-nginxdocker run-d-p 8000 root/data:/data hello:1.0 8000-- restart=always-- name ngng-v / data/registry:/var/lib/registry registry:2 background operation container port: host port container abnormal restart container name location mapping, Host location: container location, image name or ID-d background run-I (interactive),-t (Pseudo-tty) run Bash shell for input and output-- name specifies the container name If not specified, the-p host port is automatically generated to connect to the container port and exposed to the external-v host / root/data directory to connect to the container's / data directory 09. View the list of containers docker ps-a shows all containers 10. Use the start command to start container docker start or container IDdocker start hello11. Restart container docker restart or container IDdocker restart hello12. Use the attach command to connect container docker attach or container IDdocker attach hello (NAMES) Note: enter Ctrl + D or exit in Bash shell to stop and exit the docker container. If you enter Ctrl + P and Ctrl + Q in turn, the container will not be terminated but will just be launched. 13. Use the exec command to run the command within the container docker exec docker exec-ti container IDdocker exec registry ip add14. Stop container docker stop or container IDdocker psdocker stop hello15. Delete container docker rm or container IDdocker rm hellodocker ps-a16. Delete image docker rmi: or container IDdocker rmi hello-f force delete-- no-trunc delete untagged # Delete all images docker rmi $(docker images-qa) 17. Use the build command to create a mirror docker build docker build-- tag hello:1.018. Copy files using cp

Docker cp:

Docker cp 2e52e426f849:/etc/hosts. /

Docker cp fervent_lumiere:/etc/host.conf / opt/

19. Use the history command to view the image history of docker history: or container IDdocker history hello:1.0docker history tobegit3hub/seagull:latest20. Create a mirror commitdocker commit: docker commit-a "chengfeng"-m "add hello.txt" fervent_lumiere tobegit3hub/seagull:latest21. Use the diff command to check the modification of container files docker diff or container IDdocker diff hello-nginxA for added files C for modified files D for deleted files 22. Command to view inspect details docker inspect docker inspect hello-nginx23. Exe. Pull the image to the local docker tag: /: docker tag hello:1.0 localhost:5000/hello:1.0docker pull registry:latestdocker run-d-p 5000 tmp/registry 5000-after name hello-registry-v / tmp/registry:/tmp/registry registry runs, the image file is stored in the host's / image directory. 24. Push image docker push /: docker push localhost:5000/hello:1.025. Delete the tag docker rmi /: docker rmi dev.dockcloud.cn/busybox:0.126. View the log docker logs 27. Check the running status of docker stats 28. Check out topdocker top 29. View the mapped port docker port 30. Update container information docker update 31. Save the container into a tar file docker export 32. Import the tar file into the image list docker import 33. Save the container as an image docker commit running docker ID-an add author-m description 34. Save the image as a tar file docker save image ID# save image iddocker tag 56d3dc08212d registry.chinadaas.com/pubilc/elasticsearch:6.3.0# save label docker save-o elastic.tar.gz registry.chinadaas.com/pubilc/elasticsearch:6.3.035. Load tar image file docker load image ID36. External volume volumesdocker run-dti-v / web-data:/tmp:ro-- name data-container appdocker run-dti-- volumes-from data-container-- name web-container appsdocker run-dti-- volumes-from data-container-- name web2-container apps#-v host directory: container directory 37. Container Volume Management Container Volume Host Volume docker Mirror through docker build-t. Execute the dockerfile file to make FROM centos:7RUN yum install-y epel-release & &\ yum install-y nginx & &\ yum clean allEXPOSE 80 443CMD ["nginx", "- g", "daemon off;"] Container Volume FROM centos:7RUN yum install-y epel-release & &\ yum install-y nginx &\ yum clean allEXPOSE 80 443VOLUME ["/ usr/share/nginx/html"] CMD ["nginx", "- g", "daemon off" Delete the container with container volume docker rm-f-v container ID38. Delete all containers docker rm $(docker ps-Q-a) 39. Delete all images docker rmi $(docker images-Q) 40 at one time. Delete the stopped container docker rm $(docker ps-a-Q-f status=exited) 41. Delete the unlabeled image docker rmi-f $(docker images | grep "" | awk "{print\ $3}") 42. Configure docker-enter Management docker Container to add cat > > / root/.bashrc to the environment variable

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report