postgresql: Dockerfile

FROM postgres:15.2

RUN apt update
RUN apt install -y iputils-ping

COPY ./sql/ /docker-entrypoint-initdb.d/



#设置默认用户,默认数据库,默认密码
ENV POSTGRES_USER postgresql
ENV POSTGRES_DB grid_strike
ENV POSTGRES_PASSWORD 123456

# 在 Dockerfile 中添加以下命令
RUN addgroup --gid 1000 postgresql && \
    adduser --disabled-password --gecos "" --uid 1000 --ingroup postgresql postgresql

# 设置非特权用户
USER postgresql

RUN postgres
# 执行SQL文件
RUN psql -U postgresql -h localhost -d grid_strike -c "\i /docker-entrypoint-initdb.d/grid_strike.sql"

Supongo que te gusta

Origin blog.csdn.net/qq_38222947/article/details/133997347
Recomendado
Clasificación