【发布时间】:2019-09-03 14:20:17
【问题描述】:
我有一个 Node.js 应用程序的 Dockerfile,总体看起来像这样:
FROM ubuntu
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
WORKDIR /app
COPY . /app
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y -q --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
git \
libssl-dev \
wget \
postgresql-10 postgresql-client-10 postgresql-contrib-10
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER warbler WITH SUPERUSER;" &&\
createdb -O warbler warbler_store
# ... node setup stuff ...
# ...
# ...
RUN psql -U warbler -d warbler_store -f db_v1.sql
CMD ["node", "index.js"]
虽然我收到以下错误消息:
psql: 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"?
我在网上浏览了一下,我发现的大多数解决方案似乎都说 docker 正在尝试连接到 host postgres 实例,以及其他与主要目的是运行 PostgreSQL 的 docker 容器。这准确吗?如果准确,是否仍然可以运行主应用程序可以访问的容器端 PostgreSQL 实例?
【问题讨论】:
标签: node.js postgresql docker