Docker Configuration for Nexus Repository | Nuget Configuration for Docker Repository

2021年8月11日 2611点热度 0人点赞 0条评论
内容目录

Docker

If you configure a Docker private repository using Nexus but do not set the correct address for Docker, you will receive the following error when pulling images:

Error response from daemon: Get https://192.168.0.111:666/v2/: http: server gave HTTP response to HTTPS client

First, configure the Docker repository on Nexus. For example, in the image below, the port is 8082.

file

Since you are using HTTP and HTTPS, you need to modify the parameters by opening the /etc/docker/daemon.json file and adding insecure-registries, for example:

{
  "registry-mirrors": [
    "https://registry.docker-cn.com"
  ],
  "insecure-registries": ["192.168.0.111:8282", "192.158.0.111:8083"]
}

Make sure to include 8083, as it requires HTTPS.

Then restart Docker:

systemctl daemon-reload
systemctl restart docker

Next, log in to the Nexus Docker repository:

docker login 192.168.0.111:8082
Username: viwer
Password: 
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

Nuget

If you are using Visual Studio (VS), just add the private NuGet in the NuGet settings. When selecting dependencies, it will prompt for a username and password.

If you want to use a private NuGet in CI/CD, it's quite troublesome.

We can create a nuget.config configuration file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="dahui" value="http://192.168.0.111:8181/repository/nuget" />
  </packageSources>
  <packageSourceCredentials>
    <dahui>
        <add key="Username" value="你的用户名" />
        <add key="ClearTextPassword" value="你的密码" />
    </dahui>
  </packageSourceCredentials>
</configuration>

You can use encrypted passwords instead of plain text. For details, refer to
https://docs.microsoft.com/zh-cn/nuget/consume-packages/configuring-nuget-behavior
https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file

Then, during the build process, copy the nuget.config file to the same directory as the .sln file.

痴者工良

高级程序员劝退师

文章评论