'Docker: Connection from debian to postgres?
I'm trying to run a E-learning community server (ECS) https://www.freeit.de/en/campusconnect_ecs/index.html on a docker-compose system. This ECS needs a postgres-DB to be installed. So this is my first try
docker-compose.yml
version: "3"
services:
debian:
container_name: debian_test
build: './stuff'
restart: on-failure
command: ["sleep","infinity"]
links:
- db
db:
image: postgres
restart: always
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: example
ports:
- "5432:5432"
and stuff/Dockerfile:
FROM debian:stretch
RUN apt-get update && apt-get install -y \
mysql-common libpq5 libsqlite3-0 openssl libxml2 libxslt1.1 libssl1.0.2 libmariadbclient18 libevent-2.0-5 libevent-core-2.0-5 libevent-extra-2.0-5 libreadline7 apt-transport-https
So I have debian in the first container and postgres in the other container. Now I enter the debian container, where I have installed ECS...
docker exec -it debian_test bash
...run the ECS. But here I receive the error:
Called from /opt/ecs4/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
How is it possible to connect these two containers?
Best, Alex
Solution 1:[1]
First: Where is the database-connection defined? Only in the compose file? Normaly you should set at least the database-server-name somewhere.
Second: Check if the containers are running in the same network?
docker inspect CONTAINER_ID OR NAME
The section is "NetworkSettings" -> "Networks"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Philipp Schneider |
