1. 程式人生 > 其它 >Docker系列(三) Docker run 引數詳情

Docker系列(三) Docker run 引數詳情

技術標籤:dockerlinuxjava

docker run 的引數詳情

$ sudo docker run

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Run a command in a new container

一、引數

-a, --attach=[] Attach to stdin, stdout or stderr.
-c, --cpu-shares=0 CPU shares (relative weight) ---------------------# 設定cpu使用權重
–cidfile=""
Write the container ID to the file ------------------------ # 把容器id寫入到指定檔案 –cpuset="" CPUs in which to allow execution (0-3, 0,1) ----------------- # cpu繫結 -d, --detach=false Detached mode: Run container in the background, print new container id -----# 後臺執行容器 –dns=[] Set custom dns servers --
-------------- # 設定dns –dns-search=[] Set custom dns search domains -------------- # 設定dns域搜尋 -e, --env=[] Set environment variables ---------------- # 定義環境變數 –entrypoint="" Overwrite the default entrypoint of the image –env-file=[] Read in a line delimited file of ENV variables ----- # 從指定檔案讀取變數值 –expose=
[] Expose a port from the container without publishing it to your host -------- # 指定對外提供服務埠 -h, --hostname="" Container host name ---------- # 設定容器主機名 -i, --interactive=false Keep stdin open even if not attached ------------------ # 保持標準輸出開啟即使沒有attached –link=[] Add link to another container (name:alias) ----------- # 新增連結到另外一個容器 –lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf=“lxc.cgroup.cpuset.cpus = 0,1-m, --memory="" Memory limit (format: , where unit = b, k, m or g) # ------------記憶體限制 –name="" Assign a name to the container ----------------------- # 設定容器名 –net=“bridge” Set the Network mode for the container ---------------- # 設定容器網路模式 ***** ‘bridge’: creates a new network stack for the container on the docker bridge ***** ‘none’: no networking for this container ***** ‘container:<name|id>: reuses another container network stack ***** ‘host’: use the host network stack inside the container. ***** Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. -P, --publish-all=false Publish all exposed ports to the host interfaces -------- # 自動對映容器對外提供服務的埠 -p, --publish=[] Publish a container’s port to the host ------------ # 指定埠對映 ***** format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort ***** (use ‘docker port’ to see the actual mapping) –privileged=false Give extended privileges to this container ------------ # 提供更多的許可權給容器 –rm=false Automatically remove the container when it exits (incompatible with -d) ---------------------------------------- # 如果容器退出自動移除和-d選項衝突 –sig-proxy=true Proxify received signals to the process (even in non-tty mode). SIGCHLD is not proxied. # ? -t, --tty=false Allocate a pseudo-tty ---------- – # 分配偽終端 -u, --user="" Username or UID ---------------- # 指定執行容器的使用者uid或者使用者名稱 -v, --volume=[] Bind mount a volume (e.g., from the host: -v /host:/container, from docker: -v /container) ------------ # 掛載卷 –volumes-from=[] Mount volumes from the specified container(s) ------------ # 從指定容器掛載卷- -w, --workdir="" Working directory inside the container -------------- # 指定容器工作目錄

二、示例

$ sudo docker images ubuntu
在這裡插入圖片描述
$ sudo docker run -t -i -c 100 -m 512MB -h test1 -d --name=“docker_test1” ubuntu /bin/bash
在這裡插入圖片描述
$ sudo docker ps
在這裡插入圖片描述
$ sudo docker attach docker_test1
在這裡插入圖片描述