【无标题】

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
      }
相关推荐
JunLan~2 小时前
Rocky Linux 系统安装/部署 Docker
linux·docker·容器
海岛日记4 小时前
centos一键卸载docker脚本
linux·docker·centos
小袁搬码6 小时前
Windows中指定路径安装DockerDesktop
windows·docker·容器·docker desktop
qq_312920116 小时前
docker 部署 kvm 图形化管理工具 WebVirtMgr
运维·docker·容器
踏雪Vernon6 小时前
[OpenHarmony5.0][Docker][环境]OpenHarmony5.0 Docker编译环境镜像下载以及使用方式
linux·docker·容器·harmonyos
条纹布鲁斯7 小时前
dockerdsktop修改安装路径/k8s部署wordpress和ubuntu
docker·kubernetes
工业3D_大熊9 小时前
3D可视化引擎HOOPS Luminate场景图详解:形状的创建、销毁与管理
java·c++·3d·docker·c#·制造·数据可视化
szc17679 小时前
docker 相关命令
java·docker·jenkins
CP-DD9 小时前
Docker 容器化开发 应用
运维·docker·容器
Stark-C9 小时前
万物皆可Docker,在NAS上一键部署最新苹果MacOS 15系统
macos·docker·策略模式