docker常用操作(三)

三.docker run 命令

#创建并后台启动一个容器名为test,使用centos:7镜像

docker run -d -p 8888:8080 --name test --privileged -it centos:7 /usr/sbin/init

    -d : 后台运行

    -p : 端口映射 宿主机的8888端口映射到容器的8080端口(可以同时映射多个)

    --name : 为容器另起名

    --privileged:为了解决进入centos系统后使用systemctl启动服务报错

run命令详解:

-a, --attach=[]            Attach to STDIN, STDOUT or STDERR 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项

  --add-host=[]              Add a custom host-to-IP mapping (host:ip)

  --blkio-weight=0            Block IO (relative weight), between 10 and 1000

  -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

  --cpu-period=0              Limit CPU CFS (Completely Fair Scheduler) period

  --cpu-quota=0              Limit the CPU CFS quota

  --cpuset-cpus=              CPUs in which to allow execution (0-3, 0,1) 绑定容器到指定CPU运行

  --cpuset-mems=              MEMs in which to allow execution (0-3, 0,1) 绑定容器到指定MEM运行

  -d, --detach=false          Run container in background and print container ID 后台运行容器,并返回容器ID

  --device=[]                Add a host device to the container

  --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 file of environment variables 从指定文件读入环境变量

  --expose=[]                Expose a port or a range of ports

  -h, --hostname=            Container host name 指定容器的hostname

  --help=false                Print usage

  -i, --interactive=false    Keep STDIN open even if not attached 以交互模式运行容器,通常与 -t 同时使用

  --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

  --log-driver=              Logging driver for container

  --log-opt=[]                Log driver options

  --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

  --name=                    Assign a name to the container 为容器指定一个名称

  --net=bridge                Set the Network mode for the container  指定容器的网络连接类型,支持 bridge/host/none/container:<name|id> 四种类型

  --oom-kill-disable=false    Disable OOM Killer

  -P, --publish-all=false    Publish all exposed ports to random ports

  -p, --publish=[]            Publish a container's port(s) to the host

  --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

  --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 为容器重新分配一个伪输入终端,通常与 -i 同时使用

  -u, --user=                Username or UID (format: <name|uid>[:<group|gid>])

  --ulimit=[]                Ulimit options

  --uts=                      UTS namespace to use

  -v, --volume=[]            Bind mount a volume

  --volumes-from=[]          Mount volumes from the specified container(s)

  -w, --workdir=              Working directory inside the container
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AF黑眼圈患者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值