【无标题】

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

Windows开机自动重启

勾选 Start Docker Desktop when you sign in to your computer

设置容器自动启动

1.docker update 命令

bash 复制代码
	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. 使用命令进行更新设置

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

    bash 复制代码
    docker inspect <CONTAINER>
    bash 复制代码
      "RestartPolicy": {
          "Name": "always",
          "MaximumRetryCount": 0
      }
相关推荐
橙-极纪元1 小时前
把docker的镜像文件从一台服务器中,迁移至另一台服务器
服务器·docker·容器
雨声不在3 小时前
docker-android 重启后镜像起不来
android·docker·容器
宋辰轩6 小时前
Docker导致的wsl2崩溃问题
docker·wsl2
码农阿豪6 小时前
Ubuntu部署GodoOS:Docker搭建Web办公桌面并实现远程访问
前端·ubuntu·docker
纵道软件7 小时前
使用 Docker 构建自定义 SeaTunnel Web 服务镜像
前端·docker·容器
GlueNa2SiO31 天前
10-Docker生产环境部署与K8s入门
笔记·学习·docker·容器·kubernetes
蜀道山老天师1 天前
Zabbix监控Docker容器应用实践完整指南
linux·运维·docker·容器·zabbix
星空1 天前
WordPress在docker中部署
运维·docker·容器
wsad05321 天前
CentOS Stream 10 Docker 容器无法访问外网:xt_addrtype 内核模块缺失解决方法
linux·网络·docker·云原生·eureka·centos
怦怦蓝1 天前
Windows 安装 Docker Desktop 踩坑完整实战指南(WSL2 故障排错实录)
windows·docker·容器