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 and use of Docker command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "the introduction and use of Docker command". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the introduction and use of Docker commands".

1 delete all stopped containers

# docker rm $(docker ps-a-Q)

2 delete all mirrors:

# docker rmi $(docker images-Q)

3 the image created with the doker run-it image name goes directly to the container, and the image will stop after entering exit to exit. If you want to exit the container without stopping the image, you can use the ctrl + p + Q component:

Now that you have exited and found that the container instance is still running, how do you enter the container again?

You can use docker attach

4. Creation of container does not start:

Use: docker create-it-name image name

Turn it on:

# docker start-a-I

Quit using exit

5 check the status of the running container:

When viewing the status, including cpu memory Ibank O

# docker status

View all of them, including those that have stopped:

# docker stats-a

Check the status of a container:

Docker stats

To check the running status of a program in a container, you can use top:

# docker top

View the status of the files in the container:

# docker diff Diff: there are several states An indicates that the file is added, C indicates that the file is modified, D indicates that the file is deleted, 6 copies the file to the container

6 copy the file to the container

Docker cp original container: target directory # docker cp. / anaconda-ks.cfg df9b:/root/

Copy the files in the container:

# docker attach df9b/ # lsbin dev etc home proc root run sys tmp usr var# docker cp df9b:/var / root/data/

7 Docker events real-time events

View events: events

# docker events

The 8 Docker wait container blocks the container until it stops returning 0

# docker wait

9 View image history:

Docker history

10 View the underlying information of the image or container:

Docker inspect container | Image ID# docker inspect ea096efd33cc

11 View the container log

Docker logs

Check the time attached to the container log:

Docker logs-t

View real-time logs: do not exit

Docker logs-f-t

View the log information at the end of several lines:

Docker logs-t-- number of tail= rows

12 dynamically modify the configuration of the container

Ocker update: only the container needs to be restarted when the kernel is modified.

Set docker memory to 1G: the idea is to set swap first when setting memory because the test can be set to-1 infinite swap

# docker update-m 1024m-- memory-swap-1 1e indicates a memory upper limit of 1G

13 Port Mapping:

Docker port

Port mapping uses-p or-P

You can view the mapping through docker ps-a

Or use docker port ae

14 docker build build image

Docker build needs Dockerfiledocker build-t vker/box:0.3 to build an image. -t tag refers to marking the image. Represents the Dockerfile build image in the current directory

15 create a temporary test container, which will be deleted automatically when the container is running

Docker run-it-- rm centos sleep 10

16 create the container and name it

Docker run-- name container name image name

17 docker data mapping

Docker run-itd-v host directory: container directory image name

18 docker modifies the default bridge docker0 segment configuration

Cat / etc/docker/daemon.json {"bip": "10.244.1.1 Universe 24"}

19 docker View Bridge and create Delete Bridge

Docker network connect connects a container to a network docker network create creates a network docker network disconnect disconnected container network docker network inspect displays details of one or more networks docker network ls lists network docker network prune deletions Unused network docker network rm removes one or more networks-- attachable-- subnet enables manual container installation-- aux-address map [] secondary IPv4 or IPv6 address used by the network driver-- driver -d bridge driver management network-- gateway IPv4 or IPv6 gateway for the main subnet-- internal false restricts external access to the network-- ip-range Assign container ip--ipam-driver default IP address management driver from sub-scope-- ipam-opt map [] set specific options for IPAM driver-- ipv6 false enable IPv6 network-- label Set up metadata on the network-- opt -o map [] set driver specific options-subnet represents subnet 1 of the CIDR format of the network segment to create a bridge docker network create k8s is not to use-d to create a bridge type bridge by default Use-d to create other types of bridges such as overly# docker network lsNETWORK ID NAME DRIVER SCOPE54dc5bba7a69 bridge bridge local5ac666271cee host host locald0bf1b8d6884 K8s bridge local1c029239966f none null Local2 deletes a bridge docker network rm k8s 3 specified subnet to create docker network create-d bridge-- subnet=10.243.0.0/16 k8s4 sets the network scope docker network create-d bridge-- subnet=10.240.0.0/16-- ip-range=10.240.3.0/24 k8s15 container binds to the specified bridge docker run-itd-- network=k8s1-- name testnetwork busybox if omitted-- gateway flag The engine will select one from the preferred pool. For overlay networks and network driver plug-ins that support it You can create multiple subnetworks docker network create-d overlay\-- subnet=192.168.0.0/16\-- subnet=192.170.0.0/16\-- gateway=192.168.0.100\-- gateway=192.170.0.100\-- ip-range=192.168.1.0/24\-- aux-address= "my-router=192.168.1.5"-- aux-address= "my-switch=192.168.1.6"\-- aux-. Address= "my-printer=192.170.1.5"-- aux-address= "my-nas=192.170.1.6"\ Bridge driver option when creating a custom network The default network driver, that is, bridge, has other options that can be passed. Use the-o or-- opt option to specify the IP address binding when publishing the port: $docker network create\-o "com.docker.network.bridge.host_binding_ipv4" = "172.19.0.1"\ simple-network so far, I believe you have a deeper understanding of "the introduction and use of the Docker command". 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

Servers

Wechat

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

12
Report