【发布时间】:2020-09-21 16:15:49
【问题描述】:
我正在尝试在 docker 中使用 Alpine 部署我的 Go 应用程序,我能够在我的 Mac 上使用它,然后使用 Centos 8 进行生产时遇到问题 这是我的 Dockerfile:
FROM golang:alpine
RUN apk add --no-cache postgresql
RUN apk update && apk add --no-cache gcc && apk add --no-cache libc-dev && apk add --no-cache --update make
# Set the current working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. they will be cached of the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the WORKDIR inisde the container
COPY . .
# Build the Go app
RUN go build .
RUN rm -rf /usr/local/var/postgres/postmaster.pid
// this commands below like "psql -c ;'DROP DATABASE IF EXISTS prod'"
// "psql -c ;'CREATE USER prod'"
RUN make setup
# Exporse port 3000 or 8000 to the outisde world
EXPOSE 3000..
CMD ["make", "run" ]
然后我得到了错误:
psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
在我的make setup 上,我进行迁移、创建用户、数据库
也可以为那个 alpine 在 psql 上创建 SUPERUSER 吗??
你可以在上面的语法中看到什么,有什么错误以及如何纠正它?我从昨天开始卡住了
【问题讨论】:
-
请在此处发布
some syntax here......部分。删除您的密码、IP。 -
刚刚更新了@SachithMuhandiram
标签: linux postgresql docker command-line centos