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

Summarize common Docker commands

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article focuses on "summing up common Docker commands". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "summing up Docker common commands"!

Scenario 1: download, run and delete COMMANDDESC view by image

Docker images lists all images (images) docker ps lists running containers (containers) docker ps-a lists all containers docker pull centos downloads centos images docker top 'container' view containers running programs inside the container

Docker exec-it container ID sh enters the container docker stop 'container' to stop a running container 'container' can be container ID or name docker start' container' start a stopped container docker restart 'container' restart container docker rm' container' delete container docker run-I-t-p: 80 LAMP / bin/bash run container and do http port forward docker exec-it 'container' / bin/bash into bashdocker exec-it / bin/sh of ubuntu container enter shdocker rm docker ps-a-Q of alpine container delete all The stopped container docker kill $(docker ps-a-Q) kills all running containers The function of $() is the same as ``image

Docker build-t wp-api. Build 1 image,-t (name and label of the image) wp-api (image name). (built directory) docker run-Imurt wp-api-t-I runs in interactive pseudo-terminal mode, you can view the output information docker run-d-p 80:80 wp-api image port-d background mode run image docker rmi [image-id] delete image docker rmi $(docker images-Q) delete all images docker rmi $(sudo docker images-- filter "dangling=true"-Q-no-trunc) delete useless image ocker run-- help help

See Docker commands for more commands | Rookie tutorials

Scenario 2: download the image and run docker run directly-- name ubuntu-it ubuntu bash docker cp dd ubuntu:tmp/ # copy the file dd to the container's / tmp directory Ctrl-p Ctrl-q # exit scenario 3: modify the image and save it to the private repository

Expected result: add apache to the ubuntu image and save the new image to the private repository

Docker exec-it ubuntu bash apt-get updateapt-get install apache2Ctrl-p Ctrl-q # exit docker commit-a "mir355"-m "ubuntu add apache2" {ID} private/ubuntu_apache:v1 # Save the image docker stop ubuntudocker rm ubuntudocker run-I-t-- name apache2-p 8080 private/ubuntu_apache:v1 / bin/bash/etc/init.d/apache2 startCtrl-p Ctrl-q # exit # rename the image via docker tag Make it match registry docker tag private/ubuntu_apache:v1 127.0.0.1:5000/private/ubuntu_apache:v1# save to private warehouse docker push 127.0.0.1:5000/private/ubuntu_apache:v1curl http://127.0.0.1:5000/v2/_catalog# download image docker pull 127.0.0.1:5000/private/ubuntu_apache:v1 here, I believe you have a better understanding of "summarizing common Docker commands" You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

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

12
Report