安装docker时空间不足解决办法

Docker Engin 官方安装教程

1、卸载系统之前的 docker

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2、安装必须的依赖 Docker-CE

sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2

3、设置 docker repo 的 yum 位置

阿里云镜像

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、安装 docker 以及 docker-cli

sudo yum install docker-ce docker-ce-cli containerd.io

5、启动 docker

sudo systemctl start docker

6、设置 docker 开机自启

sudo systemctl enable docker

bug:安装docker时显示空间不足

[vagrant@localhost ~]$ sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.6-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.6-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.17-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.17-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.17-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.17-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.17-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.17-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                                     Arch                     Version                                        Repository                          Size
==============================================================================================================================================================
Installing:
 containerd.io                               x86_64                   1.6.6-3.1.el7                                  docker-ce-stable                    33 M
 docker-ce                                   x86_64                   3:20.10.17-3.el7                               docker-ce-stable                    22 M
 docker-ce-cli                               x86_64                   1:20.10.17-3.el7                               docker-ce-stable                    29 M
Installing for dependencies:
 audit-libs-python                           x86_64                   2.8.5-4.el7                                    base                                76 k
 checkpolicy                                 x86_64                   2.5-8.el7                                      base                               295 k
 container-selinux                           noarch                   2:2.119.2-1.911c772.el7_8                      extras                              40 k
 docker-ce-rootless-extras                   x86_64                   20.10.17-3.el7                                 docker-ce-stable                   8.2 M
 docker-scan-plugin                          x86_64                   0.17.0-3.el7                                   docker-ce-stable                   3.7 M
 fuse-overlayfs                              x86_64                   0.7.2-6.el7_8                                  extras                              54 k
 fuse3-libs                                  x86_64                   3.6.1-4.el7                                    extras                              82 k
 libcgroup                                   x86_64                   0.41-21.el7                                    base                                66 k
 libsemanage-python                          x86_64                   2.5-14.el7                                     base                               113 k
 policycoreutils-python                      x86_64                   2.5-34.el7                                     base                               457 k
 python-IPy                                  noarch                   0.75-6.el7                                     base                                32 k
 setools-libs                                x86_64                   3.3.8-4.el7                                    base                               620 k
 slirp4netns                                 x86_64                   0.4.3-4.el7_8                                  extras                              81 k

Transaction Summary
==============================================================================================================================================================
Install  3 Packages (+13 Dependent packages)

Total size: 99 M
Total download size: 97 M
Installed size: 399 M
Is this ok [y/d/N]: y
Downloading packages:


Error downloading packages:
  docker-ce-rootless-extras-20.10.17-3.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/docker-ce-stable/packages
    * free   240 k
    * needed 8.2 M
  3:docker-ce-20.10.17-3.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/docker-ce-stable/packages
    * free   240 k
    * needed 22 M
  1:docker-ce-cli-20.10.17-3.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/docker-ce-stable/packages
    * free   240 k
    * needed 29 M
  docker-scan-plugin-0.17.0-3.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/docker-ce-stable/packages
    * free   240 k
    * needed 3.7 M
  containerd.io-1.6.6-3.1.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/docker-ce-stable/packages
    * free   240 k
    * needed 33 M

解决办法:在VirtualBox界面右键删除centos7所有数据,重新安装即可

安装docker时空间不足的问题,去VirtualBox里面删除centos7,从新安装就行了,而且必须使用阿里云镜像
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
其他步骤都一样,第一此我装cenos7直接占了40G硬盘,卸载后第二次装才正常只占5G硬盘
第二次装centos7的时候先要删除pc目录下的Vagrantfile文件,然后再执行vagrant init centos/7
完成之后记得改Vagrantfile文件的配置地址config.vm.network “private_network”, ip: “192.168.56.10”

[vagrant@localhost ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[vagrant@localhost ~]$ sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
docker-ce-stable                                                                                                                       | 3.5 kB  00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo                                                                                            |   55 B  00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db                                                                                            |  80 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.7-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.7-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.17-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.17-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.17-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.17-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.17-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.17-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                                     Arch                     Version                                        Repository                          Size
==============================================================================================================================================================
Installing:
 containerd.io                               x86_64                   1.6.7-3.1.el7                                  docker-ce-stable                    33 M
 docker-ce                                   x86_64                   3:20.10.17-3.el7                               docker-ce-stable                    22 M
 docker-ce-cli                               x86_64                   1:20.10.17-3.el7                               docker-ce-stable                    29 M
Installing for dependencies:
 audit-libs-python                           x86_64                   2.8.5-4.el7                                    base                                76 k
 checkpolicy                                 x86_64                   2.5-8.el7                                      base                               295 k
 container-selinux                           noarch                   2:2.119.2-1.911c772.el7_8                      extras                              40 k
 docker-ce-rootless-extras                   x86_64                   20.10.17-3.el7                                 docker-ce-stable                   8.2 M
 docker-scan-plugin                          x86_64                   0.17.0-3.el7                                   docker-ce-stable                   3.7 M
 fuse-overlayfs                              x86_64                   0.7.2-6.el7_8                                  extras                              54 k
 fuse3-libs                                  x86_64                   3.6.1-4.el7                                    extras                              82 k
 libcgroup                                   x86_64                   0.41-21.el7                                    base                                66 k
 libsemanage-python                          x86_64                   2.5-14.el7                                     base                               113 k
 policycoreutils-python                      x86_64                   2.5-34.el7                                     base                               457 k
 python-IPy                                  noarch                   0.75-6.el7                                     base                                32 k
 setools-libs                                x86_64                   3.3.8-4.el7                                    base                               620 k
 slirp4netns                                 x86_64                   0.4.3-4.el7_8                                  extras                              81 k

Transaction Summary
==============================================================================================================================================================
Install  3 Packages (+13 Dependent packages)

Total download size: 99 M
Installed size: 399 M
Is this ok [y/d/N]: y
Downloading packages:
(1/16): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                           |  40 kB  00:00:00
(2/16): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                       |  76 kB  00:00:00
(3/16): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                               | 295 kB  00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.17-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY:08 ETA
Public key for docker-ce-20.10.17-3.el7.x86_64.rpm is not installed
(4/16): docker-ce-20.10.17-3.el7.x86_64.rpm                                                                                            |  22 MB  00:00:04
(5/16): containerd.io-1.6.7-3.1.el7.x86_64.rpm                                                                                         |  33 MB  00:00:06
(6/16): docker-ce-rootless-extras-20.10.17-3.el7.x86_64.rpm                                                                            | 8.2 MB  00:00:01
(7/16): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                                        |  54 kB  00:00:00
(8/16): libcgroup-0.41-21.el7.x86_64.rpm                                                                                               |  66 kB  00:00:00
(9/16): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm                                                                                     | 3.7 MB  00:00:00
(10/16): policycoreutils-python-2.5-34.el7.x86_64.rpm                                                                                  | 457 kB  00:00:00
(11/16): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                      | 113 kB  00:00:00
(12/16): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                          |  81 kB  00:00:00
(13/16): docker-ce-cli-20.10.17-3.el7.x86_64.rpm                                                                                       |  29 MB  00:00:04
(14/16): python-IPy-0.75-6.el7.noarch.rpm                                                                                              |  32 kB  00:00:00
(15/16): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                           | 620 kB  00:00:00
(16/16): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                             |  82 kB  00:00:02
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         8.9 MB/s |  99 MB  00:00:11
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                                    1/16
  Installing : 1:docker-ce-cli-20.10.17-3.el7.x86_64                                                                                                     2/16
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                                              3/16
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                           4/16
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                      5/16
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                              6/16
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                              7/16
  Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                          8/16
  Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                             9/16
  Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                      10/16
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                     11/16
  Installing : policycoreutils-python-2.5-34.el7.x86_64                                                                                                 12/16
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                       13/16
  Installing : containerd.io-1.6.7-3.1.el7.x86_64                                                                                                       14/16
  Installing : docker-ce-rootless-extras-20.10.17-3.el7.x86_64                                                                                          15/16
  Installing : 3:docker-ce-20.10.17-3.el7.x86_64                                                                                                        16/16
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                      1/16
  Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                             2/16
  Verifying  : docker-ce-rootless-extras-20.10.17-3.el7.x86_64                                                                                           3/16
  Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                                                                                  4/16
  Verifying  : 1:docker-ce-cli-20.10.17-3.el7.x86_64                                                                                                     5/16
  Verifying  : containerd.io-1.6.7-3.1.el7.x86_64                                                                                                        6/16
  Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                          7/16
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                        8/16
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                              9/16
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                             10/16
  Verifying  : 3:docker-ce-20.10.17-3.el7.x86_64                                                                                                        11/16
  Verifying  : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                                   12/16
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                     13/16
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                          14/16
  Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                      15/16
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                             16/16

Installed:
  containerd.io.x86_64 0:1.6.7-3.1.el7                 docker-ce.x86_64 3:20.10.17-3.el7                 docker-ce-cli.x86_64 1:20.10.17-3.el7

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7                 checkpolicy.x86_64 0:2.5-8.el7                container-selinux.noarch 2:2.119.2-1.911c772.el7_8
  docker-ce-rootless-extras.x86_64 0:20.10.17-3.el7      docker-scan-plugin.x86_64 0:0.17.0-3.el7      fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
  fuse3-libs.x86_64 0:3.6.1-4.el7                        libcgroup.x86_64 0:0.41-21.el7                libsemanage-python.x86_64 0:2.5-14.el7
  policycoreutils-python.x86_64 0:2.5-34.el7             python-IPy.noarch 0:0.75-6.el7                setools-libs.x86_64 0:3.3.8-4.el7
  slirp4netns.x86_64 0:0.4.3-4.el7_8

Complete!
  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值