高山dockerfile中的失败运行Postgres

问题描述 投票:0回答:1

我正在尝试在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上,我进行了迁移,创建了用户,数据库

也可以在psql上为该高山创建SUPERUSER吗?

您可以在上述语法中看到什么,是否有任何错误以及如何纠正它?我从昨天起就停滞了

linux postgresql docker command-line centos
1个回答
0
投票

将原始泊坞文件从第8行删除到第20行,然后添加它们。

# Copy go mod and sum files
COPY go.mod go.sum /app

# Set the current working Directory inside the container
WORKDIR /app

RUN go mod download

RUN go build .
© www.soinside.com 2019 - 2024. All rights reserved.