-i, –interactive 交互式 -t, –tty 分配一個偽終端 -d, –detach 運行容器到后台 -e, –env 設置環境變量 -p, –publish list 發布容器端口到主機 -P, –publish-all 發布容器所有EXPOSE的端口到宿主機隨機端口 –name string 指定容器名稱 -h, –hostname 設置容器主機名 ***–ip string 指定容器IP,只能用於自定義網絡 ***–network 連接容器到一個網絡 ***–mount mount 將文件系統附加到容器 *** -v, –volume list 綁定掛載一個卷 –restart string 容器退出時重啟策略,默認no,可選值:[always|on-failure] -m,–memory 容器可以使用的最大內存量 –memory-swap 允許交換到磁盤的內存量 –memory-swappiness=<0-100> 容器使用SWAP分區交換的百分比(0-100,默認為-1) –oom-kill-disable 禁用OOM Killer –cpus 可以使用的CPU數量 –cpuset-cpus 限制容器使用特定的CPU核心,如(0-3, 0,1) –cpu-shares CPU共享(相對權重) (-i -t -d --name ) root@bogon: ~ 20:54:03 $ docker run -itd --name test01 nginx:latest 91c2cc78406af33275d2322770839af779780a7013464670ad23532b7757dbe2 root@bogon: ~ 20:57:20 $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 91c2cc78406a nginx:latest "nginx -g 'daemon of…" 3 seconds ago Up 1 second 80/tcp test01 root@bogon: ~ 20:57:22 $ docker exec -it 91c2cc78406a bash root@91c2cc78406a:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@91c2cc78406a:/# (-p -e -h --memory --cpus --oom-kill-disable --restart=always) root@bogon: ~ 21:03:23
#容器名字--name test02 主機名-h test02 變量-e JAVA_HOME=/usr/local/jdk 容器退出重啟--restart=always 內存500m cpu百分之50 關閉--oom-kill-disable
$ docker run -itd --name test02 -h test02 -e JAVA_HOME=/usr/local/jdk --restart=always --memory="500m" --cpus=".5" --oom-kill-disable java:8
Unable to find image 'java:8' locally 8:
Pulling from library/java 5040bd298390:
Pull complete fce5728aad85:
Pull complete 76610ec20bf5:
Pull complete 60170fec2151:
Pull complete e98f73de8f0d:
Pull complete 11f7af24ed9c:
Pull complete 49e2d6393f32:
Pull complete bb9cdec9c7f3:
Pull complete Digest: sha256:34959eed5df6bfe74a17fbf459ed29505d51a48d5cb4a39f215b613c65b8023b Status:
Downloaded newer image for java:8 80decf3d569388332325ad864e5f1d0639d7858f39b71f41da2d3008ebe0fd7f
root@bogon: ~ 21:07:29 $