Apache反向代理到Docker容器不工作,无法解析到容器名称

hi3rlvi2  于 2023-11-21  发布在  Apache
关注(0)|答案(1)|浏览(187)

我试图让我的Apache服务器反向代理到我的Docker容器,但没有关于如何做到这一点的正确文档
我的apache虚拟主机配置代码` ServerAdmin webmaster@localhost服务器名pocketapi.gamyngcorp.com

ProxyPass / http://pocketapi:8080/
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

字符串
`

My docker compose file
services:
  pocketbot:
    build: 
      dockerfile: ./pocketbot/dockerfile
    command: java -jar /app/app.jar
    container_name: pocketbot
    hostname: pocketbot
  pocketapi:
    build: 
      dockerfile: ./pocketapi/dockerfile
    command: java -jar /app/app.jar
    container_name: pocketapi
    hostname: pocketapi
My dockerfile 
`# Use a Java runtime as a parent image
FROM ubuntu:latest

RUN apt-get update && apt-get install -y openjdk-17-jdk

RUN mkdir /app
# Copy the jar file to the container at /app
COPY pocketapi/app.jar /app

EXPOSE 8080

`

please help, I am about to quit docker all together cause of this

的数据

euoag5mw

euoag5mw1#

所以我发现我不能从主机访问docker容器,因为它们不共享相同的dns。解决方案是将apache放在docker容器中,从而使其能够访问内部docker dns

相关问题