【DOCKER】docker run的-d,-v等参数用处

这篇具有很好参考价值的文章主要介绍了【DOCKER】docker run的-d,-v等参数用处。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

0.引用

ref1

docker ps的详解

表格和文本的记录版本 

1.手册查询内容

[root@master cpu]# docker run --help

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

Run a command in a new container

Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cgroupns string                Cgroup namespace to use (host|private)
                                       'host':    Run the container in the Docker host's cgroup namespace
                                       'private': Run the container in its own private cgroup namespace
                                       '':        Use the cgroup namespace as configured by the
                                                  default-cgroupns-mode option on the daemon (default)
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container in background and print container ID
      --detach-keys string             Override the key sequence for detaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --domainname string              Container NIS domain name
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network network                Connect a container to a network
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --pull string                    Pull image before running ("always"|"missing"|"never") (default "missing")
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container
[root@master cpu]# 

2.-d

后台运行

3.-v

绑定一个数据卷

4.-p(小写)

指定要映射的IP和端口,但是在一个指定端口上只可以绑定一个容器. 支持的格式有 hostPort:containerPortip:hostPort:containerPort、 ip::containerPort

5.-P(大写)

Docker会随机映射一个 49000~49900 的端口到内部容器开放的网络端口.

6.一个样例

docker run  -v /usr/ToolsAPIDir:/ToolsAPIDir1 -d -p 5005:5004 -it toolsapi:v8 python3 tools_api.py

-v 本地目录:容器目录,挂载主机的本地目录 /usr/ToolsAPIDir 目录到容器的/ToolsAPIDir1 目录,本地目录的路径必须是绝对路径

-d 后台运行容器

-p 5005:5004指定主机的5005端口映射到容器的5004端口

-it  toolsapi:v8 以交互模式运行 toolsapi:v8启动的容器

python3 tools_api.py 启动api.py文件,这样可以不需要再Dockfile中指定 CMD命令,或者覆盖Dockfile中的CMD命令文章来源地址https://www.toymoban.com/news/detail-575651.html

到了这里,关于【DOCKER】docker run的-d,-v等参数用处的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • docker run --privileged参数(容器权限全开,不利于宿主机安全,宿主机容易重启)(与/usr/sbin/init共用)

    我在搞docker自动部署的时候,加了个 --privileged 参数,结果容器一创建,宿主机就重启了 参考网友们对–privileged参数的理解: --privileged ,权限全开,不利于宿主机安全 参考文章:docker容器权限设置–cap-add | --cap-drop | privileged 1.对外开放无认证的Docker API是非常危险的行为,

    2024年02月11日
    浏览(45)
  • 【Docker】docker run 命令详解

    Docker运行命令是在Docker中启动容器的主要方式之一。它是Docker CLI(命令行界面)中的基本命令之一,用于启动容器。 在这个语法中,“OPTIONS”包含了一些参数,用于配置和控制容器的各种方面。“IMAGE”是要使用的Docker镜像。“COMMAND”是在容器内执行的命令,“ARG”是该命

    2024年02月16日
    浏览(34)
  • docker run 与 docker start区别

    说明, docker run 和docker start 都是运行一个docker容器, 区别在于 1. docker run (使用镜像image) 2. docker start (使用容器ID或是容器NAMES)

    2024年02月14日
    浏览(38)
  • docker pull、docker load、docker run使用方法

    docker pull是从网络上下载镜像。对于镜像来说,如果不显式地指定tag,则默认会选择latest标签,即下载仓库中最新版本的镜像。 这里以下载nvidiadocker为例: 执行上方命令就可以下载这个连接中的镜像了 下载后可以使用 命令查看本机所有镜像,上方下载的镜像也会显示出来。

    2023年04月13日
    浏览(22)
  • 【Docker:Cannot connect to the Docker daemon at unix:///var/run/docker.sock.Is the docker daemon run】

    在后台一直出现xxljob环境的报错,然后查看服务器执行关于docker命令,docker images,docker ps,会一直出现如下问题: 此时已确定Docker本身已经安装正常。 问题原因是因为docker服务没有启动,所以在相应的/var/run/ 路径下找不到docker的进程。 如果未安装docker,则会出现: 1、执行

    2024年02月05日
    浏览(46)
  • Docker run命令

    docker run 命令用于创建、启动和运行一个新的 Docker 容器。它的参数如下: 参数 含义 -d 以后台模式运行容器 -p 将容器的端口映射到主机的端口 –name 为容器指定一个名称,可以在后面的命令中引用该容器 –restart 指定容器的重启策略,可以是always(默认值)、on-failure、unl

    2024年02月14日
    浏览(29)
  • Docker的run流程

    VM和Docker结构对比 1.Docker有比虚拟机更少的抽象层 2.docker利用的是宿主机的内核,vm需要是Guest OS 所以说,新建一个容器的时候,docker不需要像虚拟机一样加载一个系统内核,避免引导,虚拟机是加载Guest OS,分钟级别;而Docker是利用宿主机的操作系统,秒级 查看镜像  REPOSIT

    2024年02月11日
    浏览(21)
  • docker run 命令详解

    一、前言 Docker容器是一个开源的应用容器引擎,让开发者可以以统一的方式打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何安装了Docker引擎的服务器上(包括流行的Linux机器、Windows机器),也可以实现虚拟化。以下是Docker容器的特点: 沙箱机制:容器是

    2024年02月02日
    浏览(33)
  • Docker run命令汇总

    一、docker run指令 docker run :创建一个新的容器并运行一个命令 以下为docker run时可以加的一些参数 二、docker run指定的参数 1. -d 后台运行容器,并返回容器ID,此时不会进入交互界面,如果想要进入交互界面请加-i和-t参数。 如果用了-d参数未进入容器的时候,在想进入容器,

    2024年02月17日
    浏览(39)
  • Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running

    当docker  ps出现Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running以下报错时,首先 查看docker服务的状态如果处于关闭状态则需要启动docker服务 如果服务是启动状态docker   ps还是报这个错 如果路径ok,那就是docker.socket进程没有关掉 重新启动服务即可

    2024年02月08日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包