宝塔 Docker 更改镜像和容器的存放路径

默认都存放在系统盘,导致某些机器的系统盘负载严重,可以使用以下方式更改,请自行备份数据。

在数据盘里新建一个目录存放docker,我这里在/www/下新建一个docker文件夹,也就是/www/docker

打开以下文件修改:

/etc/docker/daemon.json

将修改写进这个json文件里:

   {
     "data-root": "/www/docker/",
     "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
   }

请注意json的书写格式。

修改完后输入命令重启docker

systemctl restart docker

有数据的,可以先数据迁移到新目录里。

  • All rights reserved.
  • No part of this website, including text and images, may be reproduced, modified, distributed, or transmitted in any form or by any means, without the prior written permission of the author.
  • Unauthorized commercial use is strictly prohibited.
  • Unauthorized personal use is strictly prohibited.