我很新的对接-写作,我试图建立一个容器与postgres 9.6之上的centos 6,并运行它与码头组合。然后,我希望能够通过一些数据库管理工具连接到数据库。
如果我跑:
docker-compose up有什么建议吗?
这是我的码头-撰写文件:
networks{}
version: '2'
services:
postgres:
build:
context: ./src/test/docker/postgres
ports:
- "5432:5432"
stdin_open: true
tty: true我的码头档案:
FROM centos:6
RUN yum -y install
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-
centos96-9.6-3.noarch.rpm
RUN yum -y install postgresql96 postgresql96-server postgresql96-libs
postgresql96-contrib postgresql96-devel
# Initialize the database (not starting it yet)
RUN service postgresql-9.6 initdb
RUN su postgres
RUN echo "listen_addresses = '*'" >> /var/lib/pgsql/9.6/data/postgresql.conf
RUN echo "PORT = 5432" >> /var/lib/pgsql/9.6/data/postgresql.conf
RUN echo "local all all trust" > /var/lib/pgsql/9.6/data/pg_hba.conf
RUN echo "host all all 127.0.0.1/32 ident" >> /var/lib/pgsql/9.6/data/pg_hba.conf
RUN echo "host all all ::1/128 ident" >> /var/lib/pgsql/9.6/data/pg_hba.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/9.6/data/pg_hba.conf
RUN exit
# Expose the PostgreSQL port
EXPOSE 5432
ENTRYPOINT service postgresql-9.6 start发布于 2017-08-01 10:12:00
您的停靠文件中的ENTRYPOINT允许您将容器配置为可执行文件。这是一种包装您需要运行的容器中所有依赖项并运行容器=运行脚本/应用程序等的方法。
现在你的切入点
ENTRYPOINT service postgresql-9.6 start只运行服务启动和退出!所以你的容器也会退出。如果要将其配置为可执行文件,则需要将postgres命令作为ENTRYPOINT命令运行。
ENTRYPOINT ["sudo","-u","postgres","/usr/pgsql-9.6/bin/postgres","-D","/var/lib/pgsql/9.6/data","-p","5432"]这将在容器启动时将postgres作为您的ENTRYPOINT命令运行,并且您应该能够连接到它。
https://stackoverflow.com/questions/45432697
复制相似问题