In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the summary of basic control commands of Docker". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the summary of basic control commands of Docker".
I. Resource control
1. CPU usage control
Limit the container created by the image to a maximum of 10% of the total resources.
Docker run-cpu-quota 10000 centos
2. Pro rata distribution
Create two containers C1 and c2. If there are only these two containers, set the weight of the container so that the proportion of CPU resources of C1 and c2 is 33.3% and 66%. 7%
Docker run-itd-- name C1-- cpu-shares 512 centos (image name)
Docker run-itd-- name c2-- cpu-shares 1024 centos (image name)
3. Restrict the container from using the specified CPU
Specify the use of four CPU for the mirror
Docker run-- name c3-- cpuset-cpus 0001, 0010, 0100, and 1000 centos.
4. Memory usage limit
Limit established containers to use 1gb memory at most
Docker run-- name c4-m 1gb centos
5. Limit the amount of data that the container can read from the disk / device
This container is limited to reading only 100mb data of sda disks.
Docker run-d-device-read-bps / dev/sda:100mb centos
6. Limit the amount of data that the container writes to the disk / device.
Restrict that the container can only write data to 100mb of sda disk
Docker run-d-device-write-bps / dev/sda:100mb centos
7. Limit the number of times the container reads the disk / device
Limit this container to read sda disk only 10 times
Docker run-d-device-read-iops / dev/sda:10 centos
8. Limit the number of times the container is written to disk / device
Limit the container to write to sda disk only 10 times
Docker run-d-device-write-iops / dev/sda:10 centos
2. Docker data volume and data volume container
1. Establish data volume (realize data sharing between container directory and host directory)
Create data volumes in interactive mode
Docker run-v local directory: container directory-name container name-it image name / bin/bash "- v" specify data volume "- name" the newly created container name / var/www:/data1 is preceded by the host directory, the latter is the container directory (the whole is the association process)
2. Establish a data volume container (data sharing between the two containers, regardless of the host environment)
Create the container in interactive mode and provide the catalog as the carrier of the data volume container
Docker run-v container directory. -- name container name-it image name / bin/bash
Mount the data volume of the container that provides space to a new container to create a data volume container
Docker run-Image name provided by volumes-from-name Container name-it Image name / bin/bash III, Docker personal Image creation 1, New Image based on existing Image 2, New Image based on Local template 3, New Image based on Dockerfile
(1) create a new image based on an existing image
Create a container docker create-it centos / bin/bash to generate a new image docker commit-m "new"-a "zhy"-p ccbd1395fce9 (container ID/ name) ccos:new (generated new image name: label) ●-m description information ●-an author information ●-p stop the container during the generation process
(2) create a new image based on the local template
Download image template wget http://download.openvz.org/teuplate/precreated/debian-7.0-x86-minimal.tar.gz to generate a new image cat debian-7.0-x86-minimal.tar.gz | docker import-daoke:new
(3) create a new image based on Dockerfile
Mkdir apachecd apachevim Dockerfile#-based basic image FROM centos# maintains the user information of the image MAINTAINER The porject # Image operation instructions install apache software RUN yum- y updateRUN yum- y install httpd# open port 80 EXPOSE 8 copy website home page file ADD index. Html/ var/www/html/index. Html# copies the execution script to the mirror ADD run. Sh / run. ShRUN chmod 755 / run. When sh# starts the container, execute the script .CMD ["/ run.sh"] vim run.shrun.FOREGROUPecho FOREGROUPecho "web test" > index.html// generates an image docker build-t httpd:centos. / / New image running container docker run-d-p 1216purl 80 httpd:centos IV, Docker port mapping
1. Mapping random ports in the container (mapping range: 49000 to 49900)
[root@localhost] # docker run-d-P httpd:centos 0820d042e62294c0db107eef0fea8c2c1fca737acb8d91306a6d40e134332bde [root@localhost ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES0820d042e622 httpd:centos "/ run.sh" 2 seconds ago Up 1 second 0.0. 0.032768-> 80/tcp epic_jennings
2. The designated port in the container is mapped
[root@localhost ~] # docker run-d-p 5566 httpd:centos9f65fc007070f36df88304515232a0d5fa357e55926a5f06b48cdf359e6ec9b8 [root@localhost ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES9f65fc007070 httpd:centos "/ run.sh" 4 seconds ago Up 4 seconds 0.0.0.0 httpd:centos9f65fc007070f36df88304515232a0d5fa357e55926a5f06b48cdf359e6ec9b8 5566-> 80/tcp intelligent_nightingale
3. Interconnection between containers
Docker run-itd-P-- name web1 centos / bin/bash / / create and run container name web1, port number automatic mapping docker run-itd-P-name web2-- link web1:web1 centos / bin/bash / / create and run container name web2 5. Establish Docker private warehouse [root@localhost tomcat] # docker pull registry / / download private warehouse registry [root@localhost nginx] # vim / etc/docker/daemon.json// add private warehouse address {"insecure-registries": ["192.168.142.77PV5000"] / / address of private warehouse "registry-mirrors": ["https://abc123.mirror.aliyuncs.com"]}// restart docker [root@localhost nginx] # systemctl stop docker [root@localhost nginx] # systemctl start docker// build containers based on warehouse images [root@localhost nginx] # docker create-it registry / bin/bash96f91f83a1d58ddee147fe3d141d27d69fa7d3d76c46e3783bef7c1c5d0339bb [root@localhost nginx] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES96f91f83a1d5 registry "/ entrypoint.sh / bin..." 5 seconds ago Created sweet_ Almeida [root @ localhost nginx] # docker run-d-p 5000Mono 5000-v / data/registry:/tmp/registry registry// change the image label (enter the address of the warehouse ) [root@localhost nginx] # docker tag nginx:zhy 192.168.142.77:5000/nginx:zhy// upload [root@localhost nginx] # docker push 192.168.142.77:5000/nginx:zhy Thank you for your reading The above is the content of "summary of basic control commands of Docker". After the study of this article, I believe you have a deeper understanding of the summary of basic control commands of Docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.