docker run

使用

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
参数描述
–add-hostAdd a custom host-to-IP mapping (host:ip)
–attach , -aAttach to STDIN, STDOUT or STDERR
–blkio-weightBlock IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
–blkio-weight-deviceBlock IO weight (relative device weight)
–cap-addAdd Linux capabilities
–cap-dropDrop Linux capabilities
–cgroup-parentOptional parent cgroup for the container
–cidfileWrite the container ID to the file
–cpu-countCPU count (Windows only)
–cpu-percentCPU percent (Windows only)
–cpu-periodLimit CPU CFS (Completely Fair Scheduler) period
–cpu-quotaLimit CPU CFS (Completely Fair Scheduler) quota
–cpu-rt-periodLimit CPU real-time period in microseconds
–cpu-rt-runtimeLimit CPU real-time runtime in microseconds
–cpu-shares , -cCPU shares (relative weight)
–cpusNumber of CPUs
–cpuset-cpusCPUs in which to allow execution (0-3, 0,1)
–cpuset-memsMEMs in which to allow execution (0-3, 0,1)
–detach , -dRun container in background and print container ID
–detach-keysOverride the key sequence for detaching a container
–deviceAdd a host device to the container
–device-cgroup-ruleAdd a rule to the cgroup allowed devices list
–device-read-bpsLimit read rate (bytes per second) from a device
–device-read-iopsLimit read rate (IO per second) from a device
–device-write-bpsLimit write rate (bytes per second) to a device
–device-write-iopsLimit write rate (IO per second) to a device
–disable-content-trust trueSkip image verification
–dnsSet custom DNS servers
–dns-optSet DNS options
–dns-optionSet DNS options
–dns-searchSet custom DNS search domains
–entrypointOverwrite the default ENTRYPOINT of the image
–env , -eSet environment variables
–env-fileRead in a file of environment variables
–exposeExpose a port or a range of ports
–group-addAdd additional groups to join
–health-cmdCommand to run to check health
–health-intervalTime between running the check (ms
–health-retriesConsecutive failures needed to report unhealthy
–health-start-periodStart period for the container to initialize before starting health-retries countdown (ms
–health-timeoutMaximum time to allow one check to run (ms
–helpPrint usage
–hostname , -hContainer host name
–initRun an init inside the container that forwards signals and reaps processes
–interactive , -iKeep STDIN open even if not attached
–io-maxbandwidthMaximum IO bandwidth limit for the system drive (Windows only)
–io-maxiopsMaximum IOps limit for the system drive (Windows only)
–ipIPv4 address (e.g., 172.30.100.104)
–ip6IPv6 address (e.g., 2001:db8::33)
–ipcIPC mode to use
–isolationContainer isolation technology
–kernel-memoryKernel memory limit
–label , -lSet meta data on a container
–label-fileRead in a line delimited file of labels
–linkAdd link to another container
–link-local-ipContainer IPv4/IPv6 link-local addresses
–log-driverLogging driver for the container
–log-optLog driver options
–mac-addressContainer MAC address (e.g., 92:d0:c6:0a:29:33)
–memory , -mMemory limit
–memory-reservationMemory soft limit
–memory-swapSwap limit equal to memory plus swap: ‘-1’ to enable unlimited swap
–memory-swappiness-1 Tune container memory swappiness (0 to 100)
–mountAttach a filesystem mount to the container
–nameAssign a name to the container
–netConnect a container to a network
–net-aliasAdd network-scoped alias for the container
–networkConnect a container to a network
–network-aliasAdd network-scoped alias for the container
–no-healthcheckDisable any container-specified HEALTHCHECK
–oom-kill-disableDisable OOM Killer
–oom-score-adjTune host’s OOM preferences (-1000 to 1000)
–pidPID namespace to use
–pids-limitTune container pids limit (set -1 for unlimited)
–platformSet platform if server is multi-platform capable
–privilegedGive extended privileges to this container
–publish , -pPublish a container’s port(s) to the host
–publish-all , -PPublish all exposed ports to random ports
–read-onlyMount the container’s root filesystem as read only
–restartno Restart policy to apply when a container exits
–rmAutomatically remove the container when it exits
–runtimeRuntime to use for this container
–security-optSecurity Options
–shm-sizeSize of /dev/shm
–sig-proxy trueProxy received signals to the process
–stop-signalSIGTERM Signal to stop a container
–stop-timeoutTimeout (in seconds) to stop a container
–storage-optStorage driver options for the container
–sysctlSysctl options
–tmpfsMount a tmpfs directory
–tty , -tAllocate a pseudo-TTY
–ulimitUlimit options
–user , -uUsername or UID (format: <name
–usernsUser namespace to use
–utsUTS namespace to use
–volume , -vBind mount a volume
–volume-driverOptional volume driver for the container
–volumes-fromMount volumes from the specified container(s)
–workdir , -wWorking directory inside the container

–restart

使用--restart来配置docker run命令

配置描述
no默认,不自动重启
on-failure重启容器,如果是因为容器运行出错,非0退出
unless-stopped重启容器,除非是docker stop 或者exit退出,也就说电脑重启也可以
always在任何情况下都要重启

docker run -dit --restart unless-stopped redis 后台可交互运行,并且是unless-stopped状态下重启

参考文献:
https://docs.docker.com/config/containers/start-containers-automatically/
https://docs.docker.com/engine/reference/commandline/run/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值