nexus 配置 docker-ce yum 源

环境说明

服务 ip 端口 备注
nexus 192.168.80.129 (内网) 8081 内网地址无法访问外网
centos7.9

192.168.80.133

 

安装docker服务
nginx

192.168.80.128 (内网)

192.168.174.126 (外网)

 88

19000

192.168.174.126 地址可以访问外网

创建 Blob Stores

创建 Repositories

 

nginx 配置

server {
    listen       19000;
    server_name  localhost;
    access_log  logs/proxy.access.log ;
    error_log  logs/proxy.error.log ;

    location /docker-ce/ {
        proxy_pass https://mirrors.huaweicloud.com/;
    }
}

docker-ce.repo

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg

构建 yum 缓存

# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                                                      | 2.2 kB  00:00:00     
docker-ce-stable                                                                                                                                                                          | 2.0 kB  00:00:00     
epel                                                                                                                                                                                      | 3.3 kB  00:00:00     
extras                                                                                                                                                                                    | 1.5 kB  00:00:00     
Not using downloaded extras/repomd.xml because it is older than what we have:
  Current   : Wed Apr  3 01:41:49 2024
  Downloaded: Wed Apr  3 01:41:48 2024
updates                                                                                                                                                                                   | 1.5 kB  00:00:00     
Not using downloaded updates/repomd.xml because it is older than what we have:
  Current   : Wed Apr  3 02:57:33 2024
  Downloaded: Wed Apr  3 02:56:32 2024
(1/12): base/7/x86_64/primary                                                                                                                                                             | 2.9 MB  00:00:00     
(2/12): base/7/x86_64/other                                                                                                                                                               | 1.5 MB  00:00:00     
(3/12): base/7/x86_64/filelists                                                                                                                                                           | 7.1 MB  00:00:00     
(4/12): docker-ce-stable/7/x86_64/filelists                                                                                                                                               |  35 kB  00:00:00     
(5/12): docker-ce-stable/7/x86_64/primary                                                                                                                                                 |  39 kB  00:00:00     
(6/12): docker-ce-stable/7/x86_64/updateinfo                                                                                                                                              |   55 B  00:00:00     
(7/12): docker-ce-stable/7/x86_64/other                                                                                                                                                   | 211 kB  00:00:00     
(8/12): epel/7/x86_64/updateinfo                                                                                                                                                          | 1.0 MB  00:00:00     
(9/12): epel/7/x86_64/prestodelta                                                                                                                                                         |  584 B  00:00:00     
(10/12): epel/7/x86_64/filelists                                                                                                                                                          |  12 MB  00:00:00     
(11/12): epel/7/x86_64/primary                                                                                                                                                            | 3.9 MB  00:00:00     
(12/12): epel/7/x86_64/other                                                                                                                                                              | 2.4 MB  00:00:00     
(1/4): extras/7/x86_64/filelists_db                                                                                                                                                       | 305 kB  00:00:00     
(2/4): extras/7/x86_64/other_db                                                                                                                                                           | 154 kB  00:00:01     
(3/4): updates/7/x86_64/other_db                                                                                                                                                          | 1.5 MB  00:00:01     
(4/4): updates/7/x86_64/filelists_db                                                                                                                                                      |  14 MB  00:00:17     
base                                                                                                                                                                                                 10072/10072
base                                                                                                                                                                                                 10072/10072
base                                                                                                                                                                                                 10072/10072
docker-ce-stable                                                                                                                                                                                         313/313
docker-ce-stable                                                                                                                                                                                         313/313
docker-ce-stable                                                                                                                                                                                         313/313
epel                                                                                                                                                                                                 13798/13798
epel                                                                                                                                                                                                 13798/13798
epel                                                                                                                                                                                                 13798/13798
Metadata Cache Created

安装 docker-ce

# sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
...
Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                                  Arch                                  Version                                                    Repository                                       Size
=================================================================================================================================================================================================================
Installing:
 containerd.io                                            x86_64                                1.6.31-3.1.el7                                             docker-ce-stable                                 35 M
 docker-buildx-plugin                                     x86_64                                0.13.1-1.el7                                               docker-ce-stable                                 14 M
 docker-ce                                                x86_64                                3:26.0.1-1.el7                                             docker-ce-stable                                 27 M
 docker-ce-cli                                            x86_64                                1:26.0.1-1.el7                                             docker-ce-stable                                 14 M
 docker-compose-plugin                                    x86_64                                2.26.1-1.el7                                               docker-ce-stable                                 13 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                                26.0.1-1.el7                                               docker-ce-stable                                9.4 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
 libseccomp                                               x86_64                                2.3.1-4.el7                                                base                                             56 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

...
Total                                                                                                                                                                             61 MB/s | 114 MB  00:00:01     
Retrieving key from http://192.168.80.129:8081/repository/docker-ce-huawei-repo/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       : http://192.168.80.129:8081/repository/docker-ce-huawei-repo/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
...
Installed:
  containerd.io.x86_64 0:1.6.31-3.1.el7    docker-buildx-plugin.x86_64 0:0.13.1-1.el7    docker-ce.x86_64 3:26.0.1-1.el7    docker-ce-cli.x86_64 1:26.0.1-1.el7    docker-compose-plugin.x86_64 0:2.26.1-1.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:26.0.1-1.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                           libseccomp.x86_64 0:2.3.1-4.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!

验证 docker-ce 版本信息

启动 docker 服务

# systemctl enable docker --now
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

验证 docker-ce 版本

# docker version
Client: Docker Engine - Community
 Version:           26.0.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        d260a54
 Built:             Thu Apr 11 10:56:30 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       60b9add
  Built:            Thu Apr 11 10:55:26 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

参考文档:

https://help.sonatype.com/en/docker-registry.html#/

posted @ 2024-04-19 09:00  小吉猫  阅读(68)  评论(0编辑  收藏  举报