zl程序教程

您现在的位置是:首页 >  工具

当前栏目

Nexus3 配置 docker 仓库

Docker配置 仓库
2023-09-14 09:06:41 时间

1、启动脚本,增加一个 8082 端口给 docker 仓库

vim start.sh
 
# 内容
docker rm -f nexus || true
docker run --name nexus \
-p 8081:8081 \
-p 8082:8082 \
-v /docker/nexus/nexus-data:/nexus-data \
--restart=always \
-d sonatype/nexus3

2、创建一个 docker 仓库,这里选择 docker (hosted)

3、输入仓库名字,HTTP 端口号,允许与 API 交互

4、配置 Realms

5、在另一机器登陆仓库,先配置 docker

{
    "registry-mirrors": ["http://hub-mirror.c.163.com"],
    "insecure-registries":["harbor.mshxuyi.com","192.168.2.107:8082"]
}

6、重启 docker 

# 重新加载(有些Docker版本需要)
systemctl daemon-reload

# 重启
systemctl restart docker

# 登陆成功
[root@jenkins ~]# docker login -u admin -p admin123 192.168.2.107:8082
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

7、上传镜像

# 拉取一个镜像
[root@jenkins ~]# docker pull busybox

# 给镜像打 tag
[root@jenkins ~]# docker tag busybox 192.168.2.107:8082/busybox:v1

# 上传
[root@jenkins ~]# docker push 192.168.2.107:8082/busybox:v1

8、查看,成功显示