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

Introduction to Common commands of Docker Container

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

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.

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