Get the App
SLTechnology News&Howtos  ›  Servers  › 

Introduction to Common commands of Docker Container

Shulou Source: shulou.com Published: 2022-06-03 05:35:52 10月27日 Update

Today, Xiaobian shared with you the introduction of common commands for Docker containers. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.

Download docker image:

docker pull xxxx

View image list:

docker images

View all containers:

docker ps -a

start/stop docker container:

docker start/stop 92959a6799c3 (92959a6799c3 is container ID)

Batch stop container:

docker stop $(docker ps -a -q)

Delete container:

docker rm 92959a6799c3

Bulk Delete Containers:

docker rm $(docker ps -a -q)

Delete local image:

docker rmi 10.0.0.2:500/ming:1.0

Enter existing container:

docker attach 92959a6799c3

Upload docker image:

docker tag image:ubuntu1604_v2 10.0.0.2:5000/ubuntu1604_v2docker push 10.0.0.2:5000/ubuntu1604_v2

Permission to start docker container for normal accounts:

gpasswd -a aa docker

Start and enter container:

$ docker run -it ubuntu1604_v1 /bin/bash

or

$ docker run -it 10.0.0.2:5000/ubuntu1604_v1 /bin/bash

Mount the host directory to the container (host directory before, container directory after, automatically generated if container directory does not exist):

$ docker run -it -v /home/super:/home/super 10.0.0.2:5000/ubuntu1604_v1 /bin/bash

Copy data from host to docker container:

docker cp /home/aa 92959a6799c3:/home/

Copy data from docker container to host:

docker cp 92959a6799c3:/home/aa /home/

Save container as mirror:

docker commit 52f44bc1b909 image:ubuntu1604_v2

Export docker container:

docker export 52f44bc1b909 > aa.tar

Import docker container as image:

cat aa.tar | docker import - ubuntu16:1.0

Export image (0cdfc5c78542 is image ID):

docker save 0cdfc5c78542 > aa.tar

Import image:

docker load < aa.tar

Convert iso to docker image:

mkdir isomount -o loop ubuntu-14.04.3-server-amd64.iso iso/tar czfv ubuntu14043iso.tar.gz isocat ubuntu14043iso.tar.gz |docker import - ubuntu:server_14.04.3 (import image)

Common commands about Docker containers are shared here. I hope the above content can help you and learn more. If you like this post, share it with more people.

Tags: Containers hosts directories commands commonly used hosts data more practical common for this content permissions see knowledge articles automatic generation accounts images references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Shulou Technology Linux Apple