Docker 容器命令详细笔记-工作中常用

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

Run a command in a new container
  -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
  --add-host=[]              Add a custom host-to-IP mapping (host:ip)  //指定一个host指向到容器内部
  -c, --cpu-shares=0         CPU shares (relative weight)
  --cap-add=[]               Add Linux capabilities
  --cap-drop=[]              Drop Linux capabilities
  --cgroup-parent=           Optional parent cgroup for the container
  --cidfile=                 Write the container ID to the file
  --cpuset-cpus=             CPUs in which to allow execution (0-3, 0,1)
  -d, --detach=false         Run container in background and print container ID  //后端持续运行
  --device=[]                Add a host device to the container
  --dns=[]                   Set custom DNS servers 
  --dns-search=[]            Set custom DNS search domains
  -e, --env=[]               Set environment variables//见Dockfile中的ENV
  --entrypoint=              Overwrite the default ENTRYPOINT of the image
  --env-file=[]              Read in a file of environment variables
  --expose=[]                Expose a port or a range of ports
  -h, --hostname=            Container host name  //指定容器主机名
  --help=false               Print usage
  -i, --interactive=false    Keep STDIN open even if not attached //打开标准输入
  --ipc=                     IPC namespace to use
  -l, --label=[]             Set meta data on a container
  --label-file=[]            Read in a line delimited file of labels
  --link=[]                  Add link to another container  // 设置容器互联,指定当前容器跟哪个容器互联,提供安全且不暴露与公网、vpc
  --log-driver=              Logging driver for container
  --lxc-conf=[]              Add custom lxc options
  -m, --memory=              Memory limit    //内存限制
  --mac-address=             Container MAC address (e.g. 92:d0:c6:0a:29:33)
  --memory-swap=             Total memory (memory + swap), '-1' to disable swap //指定swap或禁用swap
  --name=                    Assign a name to the container  //指定容器名字
  --net=bridge               Set the Network mode for the container  //指定容器网络模式
  -P, --publish-all=false    Publish all exposed ports to random ports//公开Dockfile 中的保留端口到随机端口
  -p, --publish=[]           Publish a container's port(s) to the host //指定映射宿主机端口到容器端口(80则宿主机端口随机,(1)在ps中可以查看,(2) docker port name/id 端口)
  --pid=                     PID namespace to use
  --privileged=false         Give extended privileges to this container
  --read-only=false          Mount the container's root filesystem as read only
  --restart=no               Restart policy to apply when a container exits//检查容器退出代码,自动重启容器。例如: --restart=on-failure:5 //退出代码为非0时,才会自动重启。--restart=always 总是重启
  --rm=false                 Automatically remove the container when it exits//退出时自动删除
  --security-opt=[]          Security Options
  --sig-proxy=true           Proxy received signals to the process
  -t, --tty=false            Allocate a pseudo-TTY //启用虚拟终端
  -u, --user=                Username or UID (format: <name|uid>[:<group|gid>])//见Dockfile中的USER
  --ulimit=[]                Ulimit options
  -v, --volume=[]            Bind mount a volume//加载卷列表 见Dockfile中的VOLUME
  --volumes-from=[]          Mount volumes from the specified container(s) //挂载数据卷容器
  -w, --workdir=             Working directory inside the container//指定容器工作目录 见Dockfile中的WORKDIR

转载请注明:西数超哥博客» Docker 容器命令详细笔记-工作中常用 西数超哥博客,数据库,西数超哥,虚拟主机,域名注册,域名,云服务器,云主机,云建站,


原创文章,作者:zhang sir,如若转载,请注明出处: