[英]I can't login docker using nginx as reverse proxy server for nexus
I have environment builded with docker-compose. 我已经用docker-compose构建了环境。 Nexus website is working fine but I can't login with docker. Nexus网站运行正常,但无法登录docker。
This is the error I get when I try to log in 这是我尝试登录时遇到的错误
C:\\Users\\j0nl1>docker login repository.localhost C:\\ Users \\ j0nl1> docker登录存储库.localhost
Username: admin 用户名:admin
Password: 密码:
Error response from daemon: Get http://repository.localhost/v2/ : dial tcp: lookup repository.localhost on 192.168.65.1:53: no such host 来自守护程序的错误响应:获取http://repository.localhost/v2/ :拨打tcp:查找192.168.65.1:53上的repository.localhost:没有这样的主机
My default.conf file: 我的default.conf文件:
worker_processes 2;
events {
worker_connections 1024;
}
http {
error_log /var/log/nginx/error.log warn;
access_log /dev/null;
proxy_intercept_errors off;
proxy_send_timeout 120;
proxy_read_timeout 300;
server {
listen 80;
location / {
proxy_pass http://web:3000;
}
}
upstream nexus {
server nexus:8081;
}
upstream registry {
server nexus:8082;
}
server {
listen 80;
server_name repository.localhost;
keepalive_timeout 5 5;
proxy_buffering off;
# allow large uploads
client_max_body_size 1G;
location / {
# redirect to docker registry
if ($http_user_agent ~ docker ) {
proxy_pass http://registry;
}
proxy_pass http://nexus;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
docker-compose file: docker-compose文件:
version: '3'
services:
web:
build: './web'
ports:
- "3000:3000"
nexus:
build: './nexus'
ports:
- "8081:8081"
- "8082:8082"
- "8083:8083"
volumes:
- c:/docker/nexus:/nexus-data
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./default.conf:/etc/nginx/nginx.conf
depends_on:
- web
- nexus
Nexus DockerFile: Nexus DockerFile:
FROM sonatype/nexus3:3.17.0
EXPOSE 8081-8083
将此添加到您的主机文件
127.0.0.1 repository.localhost
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.