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

What are the options for creating common parameters for docker containers

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

Share

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

This article mainly explains "what are the common parameter options for creating docker containers". 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 what are the common parameter options for creating docker containers.

1. Common options for docker run to create containers

1.1 create a container

Option description-iQuery chatter interactive interactive-TMagneLetty assigns a pseudo terminal-dMagne talk detach runs the container to the background-eQuery talk env sets the environment variable-p (lowercase),-publish list publishes the container port to host-P (uppercase),-publish-all publishes the container port of all EXPOSE to host random port-name string specifies container name-ip string specifies container host name-ip string specifies container IP Can only be used for customizing the network-network connection container to a network-restart string volume list binding mounts a volume-restart policy when the restart string container exits. Default is no. Available value: [always | on-failure]

1. 2 container resource restrictions

Option description-maximum amount of memory that can be used by the memory-swap Murray memory container-amount of memory allowed to be swapped to disk by memory-swap-percentage of memory-swappiness= containers swapped using swap partitions (0-100, default is-1)-oom-kill-disable forbids the number of cpu that OOM killer--cpus can use-cpuset-cpus limits containers to use specific cpu cores, such as (0-3,0)-cpu-sharescpu sharing (relative weight)

2. Use docker run to create containers

2.1 docker run-it creates a container and enters the container

1 [root@test-2 ~] # docker run-it nginx

2.2 docker run-d create a container and run it in the background

1 [root@test-1 playbooks] # docker run-it-d nginx

2.3 docker run-e create a container and set the environment variable

1 [root@test-1 playbooks] # docker run-it-d-e test=123456 nginx

2.4 docker run-it-d-p80 80 create a container and set the local port corresponding to the container port

1 [root@test-1 playbooks] # docker run-it-d-p80 it 80 nginx

2.5 docker run-it-name webnginx creates a container and sets the name of a container

1 [root@test-1 playbooks] # docker run-it-d-name webnginx nginx

2.6 docker run-it-d-P (uppercase p) creates a container and randomly assigns a local port corresponding to the container port

1 [root@test-1] # docker run-it-d-name web1-P nginx

3. Docker container resource restrictions

3.1 case 1-memory limit-m parameter, allows the container to use up to 500m of memory and 100m of swap, and disables OOM killer

1 [root@test-1 ~] # docker run-it-d-- name nginx03-- memory= "500m"-- memory-swap= "100m"-- oom-kill-disable nginx2 [root@test-1 ~] # docker stats nginx03 # View the running status

3.2 cpu limit, which allows the container to use up to one cpu

1 [root@test-1 ~] # docker run-it-d-- name nginx04-- cpus= "1" nginx2 # allows containers to use up to 50% of cpu3 [root@test-1 ~] # docker run-it-d-name nginx05-- cpus= ".5" nginx thanks for your reading. That's what are the common parameter options for creating docker containers. After the study of this article, I believe you have a deeper understanding of what are the common parameter options for creating docker containers, and the specific usage 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.

Share To

Internet Technology

Wechat

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

12
Report