【无标题】

Docker开机自动重启及自动启动容器

Windows开机自动重启

勾选 Start Docker Desktop when you sign in to your computer
在这里插入图片描述

设置容器自动启动

1.docker update 命令

	Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]
	
	Update configuration of one or more containers
	
	Aliases:
	  docker container update, docker update
	
	Options:
	      --blkio-weight uint16        Block IO (relative weight), between 10
	                                   and 1000, or 0 to disable (default 0)
	      --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 the CPU real-time period in
	                                   microseconds
	      --cpu-rt-runtime int         Limit the 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)
	  -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
	      --pids-limit int             Tune container pids limit (set -1 for
	                                   unlimited)
	      --restart string             Restart policy to apply when a
	                                   container exits
  1. restart命令详解

    Use the --restart flag to specify a container’s restart policy. A restart policy controls whether the Docker daemon restarts a container after exit. Docker supports the following restart policies:

    Policy Result
    no Do not automatically restart the container when it exits. This is the default.
    on-failure[:max-retries] Restart only if the container exits with a non-zero exit status. Optionally, limit the number of restart retries the Docker daemon attempts.
    unless-stopped Restart the container unless it’s explicitly stopped or Docker itself is stopped or restarted.
    always Always restart the container regardless of the exit status. When you specify always, the Docker daemon tries to restart the container indefinitely. The container always starts on daemon startup, regardless of the current state of the container.
  2. 使用命令进行更新设置

    docker update --restart=always <CONTAINER>
    
  3. 查看是否设置成功,检查RestartPolicy内容

    docker inspect <CONTAINER>
    
      "RestartPolicy": {
          "Name": "always",
          "MaximumRetryCount": 0
      }
    

相关推荐

  1. 标题

    2024-06-19 08:10:02       47 阅读
  2. 标题

    2024-06-19 08:10:02       44 阅读
  3. 标题

    2024-06-19 08:10:02       42 阅读
  4. 标题

    2024-06-19 08:10:02       49 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-19 08:10:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-19 08:10:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-19 08:10:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-19 08:10:02       20 阅读

热门阅读

  1. 从0到1上线小程序的步骤

    2024-06-19 08:10:02       5 阅读
  2. 虚设备与Spooling技术

    2024-06-19 08:10:02       5 阅读
  3. 【100个C++面试题和解答】

    2024-06-19 08:10:02       7 阅读
  4. 数据结构——顺序表的实现

    2024-06-19 08:10:02       8 阅读
  5. 「前端+鸿蒙」鸿蒙应用开发-布局

    2024-06-19 08:10:02       10 阅读
  6. 拥抱未来:探索改变游戏规则的新存储技术

    2024-06-19 08:10:02       7 阅读
  7. LLM大语言模型(GPT)的分布式预训练与微调及部署

    2024-06-19 08:10:02       11 阅读
  8. 创建最基本的web服务器-http模块

    2024-06-19 08:10:02       7 阅读
  9. cpp混淆详解

    2024-06-19 08:10:02       11 阅读
  10. ListMapToExcel

    2024-06-19 08:10:02       8 阅读