-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 # 提供更多的权限给容器 --restart="" Restart policy to apply when a container exits (no, on-failure[:max-retry], always) --rm=false Automatically remove the container when it exits (incompatible with -d) # 如果容器退出自动移除和 -d 选项冲突 --security-opt=[] Security Options
--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
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 e54ca5efa2e9 4 weeks ago 276.5 MB
... ... $ sudo docker run -t -i -c 100 -m 512MB -h test1 -d --name="docker_test1" ubuntu /bin/bash # 创建一个 cpu 优先级为 100,内存限制 512MB,主机名为 test1,名为 docker_test1 后台运行 bash 的容器 a424ca613c9f2247cd3ede95adfbaf8d28400cbcb1d5f9b69a7b56f97b2b52e5 $ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a424ca613c9f ubuntu:14.04 /bin/bash 6 seconds ago Up 5 seconds docker_test1 $ sudo docker attach docker_test1
root@test1:/# pwd /
root@test1:/# exit exit 关于cpu优先级:
By default all groups have 1024 shares. A group with 100 shares will get a ~10% portion of the CPU time -archlinux cgroups
4.8 docker start|stop|kill… …
dockerstart|stop|kill|restart|pause|unpause|rm|commit|inspect|logs
docker start CONTAINER [CONTAINER…]# 运行一个或多个停止的容器
docker stop CONTAINER [CONTAINER…]# 停掉一个或多个运行的容器-t选项可指定超时时间
docker kill [OPTIONS] CONTAINER [CONTAINER…]# 默认 kill 发送 SIGKILL 信号-s可以指定发送 kill 信号类型
docker restart [OPTIONS] CONTAINER [CONTAINER…]# 重启一个或多个运行的容器-t选项可指定超时时间
docker pause CONTAINER# 暂停一个容器,方便 commitdocker unpause CONTAINER# 继续暂停的容器
docker rm [OPTIONS] CONTAINER [CONTAINER…]# 移除一个或多个容器
-f, –force=false Force removal of running container










