-l, –link=false Remove the specified link and not the underlying container
-v, –volumes=false Remove the volumes associated with the container
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]# 提交指定容器为镜像
-a, –author=”” Author (e.g., “John Hannibal Smith hannibal@a-team.com”)
-m, –message=”” Commit message
-p, –pause=true Pause container during commit# 默认 commit 是暂停状态
docker inspect CONTAINER|IMAGE [CONTAINER|IMAGE…]
# 查看容器或者镜像的详细信息docker logs CONTAINER# 输出指定容器日志信息
-f, –follow=false Follow log output# 类似 tail -f
-t, –timestamps=false Show timestamps
–tail=”all” Output the specified number of lines at the end of logs (defaults to all logs)
参考文档:Docker Run Reference
4.9 Docker 1.3 新增特性和命令Digital Signature Verification
Docker 1.3 版本将使用数字签名自动验证所有官方库的来源和完整性,如果一个官方镜像被篡改或者被破坏,目前 Docker 只会对这种情况发出警告而并不阻止容器的运行。
docker exec --helpUsage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] Run a command in an existing container
-d, --detach=false Detached mode: run command in the background
-i, --interactive=false Keep STDIN open even if not attached
-t, --tty=false Allocate a pseudo-TTY
为了简化调试,可以使用docker exec命令通过 Docker API 和 CLI 在运行的容器上运行程序。
$ docker exec -it ubuntu_bash bash
上例将在容器 ubuntu_bash 中创建一个新的 Bash 会话。
Tune container lifecycles withdocker create
我们可以通过docker run <image name>命令创建一个容器并运行其中的程序,因为有很多用户要求创建容器的时候不启动容器,所以docker create应运而生了。
$ docker create -t -i fedora bash6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
上例创建了一个可写的容器层 (并且打印出容器 ID),但是并不运行它,可以使用以下命令运行该容器:
$ docker start -a -i 6d8af538ec5bash-4.2#
Security Options
通过–security-opt选项,运行容器时用户可自定义 SELinux 和 AppArmor 卷标和配置。
$ docker run –security-opt label:type:svirt_apache -i -t centos bash
上例只允许容器监听在 Apache 端口,这个选项的好处是用户不需要运行 docker 的时候指定–privileged选项,降低安全风险。
参考文档:Docker 1.3: signed images, process injection, security options, Mac shared directories
4.10 Docker 1.5 新特性
参考文档:Docker 1.5 新特性
五、Docker 端口映射
# Find IP address of container with ID <container_id> 通过容器 id 获取 ip $ sudo docker inspect <container_id> | grep IPAddress | cut -d ‘”‘ -f 4










