Search code examples
dockerapachedocker-compose

Apache reverse proxy to docker container doesnt work. cant resolve to container name


I am try to have my apache server reverse proxy to my docker containers, but there is 0 correct documentation on how to do this

My apache virtual host conf code ` ServerAdmin webmaster@localhost ServerName 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

Solution

  • So i turns out I can't access the docker container from the host, as they dont share the same dns. The solution was to just put the apache in a docker container thus giving it access to the internal docker dns