Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Summarize common Docker commands

Shulou Source: shulou.com Published: 2022-06-02 03:41:43 09月13日 Update

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!

Tags: Mirror Container run Command commonly used Warehouse scene being Private content more Mode Directory Port Learning practical deeper Information interest function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Information Docker Apple NVidia