Docker dockerfile erp问题

问题描述 投票:0回答:1
[root@k8s-master-node1 ERP]# cat Dockerfile-erp   
FROM centos:centos7.9.2009
RUN rm -rf /etc/yum.repos.d/*
COPY yum /root/yum
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-*
ADD app.jar /root/
EXPOSE 9999
CMD ["java","-jar","/root/app.jar"]
[root@k8s-master-node1 ERP]# cat Dockerfile-nginx 
FROM centos:centos7.9.2009
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY yum /root/yum
RUN yum -y install nginx
ADD nginx /etc/nginx
EXPOSE 80
CMD ["nginx","-g","daemon off;"

docker-compose

[root@k8s-master-node1 ERP]# cat docker-compose.yaml 
version: '3'
services:
  mariadb:
    image: erp-mariadb:v1.0 
    container_name: erp-mariadb
    restart: always
    ports:
      - "3306:3306"
    networks:
      - erp-net

  redis:
    image: erp-redis:v1.0
    container_name: erp-redis
    restart: always
    ports:
      - "6379:6379"
    networks:
      - erp-net

  nginx:
    image: erp-nginx:v1.0
    container_name: erp-nginx
    restart: always
    ports:
      - "8080:80"
    networks:
      - erp-net

  erp:
    image: erp:v1.0
    container_name: erp
    restart: always
    ports:
      - "9999:9999"
    networks:
      - erp-net

networks:
  erp-net:

nginx.conf

[root@k8s-master-node1 ERP]# cat nginx/nginx.conf    
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 10m;

    server {
        listen       80;

        location / {
            root /app;
            try_files $uri $uri/ /index.html $uri/ =404;
            index  index.html index.htm;
        }
        location /jshERP-boot/ {
                proxy_pass http://erp-server:9999/jshERP-boot/;
                proxy_set_header Host $host:$server_port;
        }
    }
}
[root@k8s-master-node1 ERP]# docker ps | grep erp
2f7a8ec20c8c   erp-nginx:v1.0                       "nginx -g 'daemon of…"   11 minutes ago   Restarting (1) 29 seconds ago                                               erp-nginx
c45f1d43148c   erp-redis:v1.0                       "/bin/sh -c 'redis-s…"   11 minutes ago   Up 11 minutes                   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   erp-redis
154d8a083da3   erp:v1.0                             "java -jar /root/app…"   11 minutes ago   Restarting (1) 7 seconds ago                                                erp
099eee888a84   erp-mariadb:v1.0                     "mysqld_safe --user=…"   11 minutes ago   Up 11 minutes                   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp   erp-mariadb
[root@k8s-master-node1 ERP]# docker logs --tail 50 --follow --timestamps 2f7a8ec20c8c
2023-09-04T22:50:23.555442967Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.300262102Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.958909792Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:25.816261977Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:27.062843605Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:29.151060619Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:32.750432089Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:39.618648965Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:52.873706828Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:51:18.882991669Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24

如何解决?

您收到的错误消息似乎与您的 Nginx 服务器的配置有关。该错误消息表明在您的 Nginx 配置文件的上游部分中找不到主机“erp-server”1

[root@k8s-master-node1 ERP]# docker logs --tail 50 --follow --timestamps 2f7a8ec20c8c
2023-09-04T22:50:23.555442967Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.300262102Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.958909792Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:25.816261977Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:27.062843605Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24

第 22 行

                proxy_pass http://erp-server:9999/jshERP-boot/;

不知道大家对segment有没有混淆。我对此没有太多基础。

docker nginx docker-compose dockerfile erp
1个回答
0
投票

正如您提到的,nginx 配置似乎是错误的。

proxy_pass http://erp-server:9999/jshERP-boot/;

erp-server
未在您的
compose
文件中列出。您应该将其更改为您拥有的服务。在这种情况下
erp

proxy_pass http://erp:9999/jshERP-boot/;
© www.soinside.com 2019 - 2024. All rights reserved.