Hi there, I am actually trying to connect my app container to Redis container. However, there is a connection error: Carmine connection error {}
This is my docker file:
FROM clojure:openjdk-8-lein-2.9.6
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app/
RUN lein deps
COPY . /usr/src/app
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
CMD ["java", "-jar", "app-standalone.jar"]
Please note that I ensure that the Redis container is up and running before running my app container.
My question to this is, do we need to do some configuration in the Dockerfile to create some sort of tunnel between my app container and Redis container to be able to get the connection?
Good evening, localhost from within a docker-container is NOT the Docker-host’s localhost.
On Windows you can use host.docker.internal to connect to the Docker-host.
On linux you can use 172.17.0.1 which is the Docker-host in Docker’s default network.
Both options above require that you have forwarded the redis-container’s port 6379 to the Docker-host using docker run -p 6379:6379 ... (see docker run | Docker Documentation)
Or you can use the container’s name as DNS-name to connect to from one container to another.
But localhost from within a Docker-container will not work