Docker:从Debian到Postgres的连接?
我正在尝试运行电子学习社区服务器(ECS) 在Docker-Compose系统上。此ECS需要安装Postgres-DB。因此,这是我的第一个尝试
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"
和suck/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
所以我将debian放在第一个容器中,而在另一个容器中有postgres。现在,我进入了已安装ECS的Debian容器...
docker exec -it debian_test bash
...运行ECS。但是在这里我收到错误:
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"?
如何连接这两个容器?
最好的, 亚历克斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:数据库连接在哪里定义?仅在撰写文件中?通常,您应该至少在某处设置数据库服务器名称。
第二:检查容器是否在同一网络中运行?
本节是“ NetworkSettings” - > “网络”
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?
The section is "NetworkSettings" -> "Networks"