标签:closed 技术 code plugin daemon bsp 用户 style play
安装docker
sudo apt-get install docker.io
创建文件目录
mkdir docker-images
修改本地存储路径
# 查看服务状态 sudo systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2021-05-02 04:56:41 UTC; 11min ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 28511 (dockerd) Tasks: 12 CGroup: /system.slice/docker.service └─28511 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock May 02 04:56:39 ubuntu dockerd[28511]: time="2021-05-02T04:56:39.992738149Z" level=warning msg="Your kernel does not support CPU realtime scheduler" May 02 04:56:39 ubuntu dockerd[28511]: time="2021-05-02T04:56:39.992763389Z" level=warning msg="Your kernel does not support cgroup blkio weight" May 02 04:56:39 ubuntu dockerd[28511]: time="2021-05-02T04:56:39.992787055Z" level=warning msg="Your kernel does not support cgroup blkio weight_device" May 02 04:56:39 ubuntu dockerd[28511]: time="2021-05-02T04:56:39.993370353Z" level=info msg="Loading containers: start." May 02 04:56:40 ubuntu dockerd[28511]: time="2021-05-02T04:56:40.599575280Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address" May 02 04:56:40 ubuntu dockerd[28511]: time="2021-05-02T04:56:40.918501020Z" level=info msg="Loading containers: done." May 02 04:56:41 ubuntu dockerd[28511]: time="2021-05-02T04:56:41.068450159Z" level=info msg="Docker daemon" commit="20.10.2-0ubuntu1~20.04.2" graphdriver(s)=overlay2 version=20.10.2 May 02 04:56:41 ubuntu dockerd[28511]: time="2021-05-02T04:56:41.069034679Z" level=info msg="Daemon has completed initialization" May 02 04:56:41 ubuntu systemd[1]: Started Docker Application Container Engine. May 02 04:56:41 ubuntu dockerd[28511]: time="2021-05-02T04:56:41.210015399Z" level=info msg="API listen on /run/docker.sock" u
# 编辑服务文件 sudo vi /lib/systemd/system/docker.service # 添加 --graph="/data/docker-images" ExecStart=/usr/bin/dockerd --graph="/data/docker-images" -H fd:// --containerd=/run/containerd/containerd.sock
重启服务
systemctl daemon-reload sudo systemctl restart docker
使用国内镜像服务器
vi /etc/docker/daemon.json # 添加以下内容(网易镜像仓库) { "registry-mirrors": [ "https://hub-mirror.c.163.com" ] }
测试
sudo docker pull ubuntu
查看镜像是否下载到/data/docker-images
sudo du -d 1 -h
结果如下:
4.0K ./swarm 4.0K ./tmp 4.0K ./trust 88K ./buildkit 40K ./network 72M ./overlay2 332K ./image 16K ./plugins 4.0K ./runtimes 4.0K ./containers 28K ./volumes 72M .
修改用户权限,docker指令不需要sudo
sudo gpasswd -a ubuntu docker sudo newgrp docker sudo systemctl restart docker
标签:closed 技术 code plugin daemon bsp 用户 style play
原文地址:https://www.cnblogs.com/liubin0509/p/14725615.html