我正在编写一个Dockerfile
,它引入外部转储,然后加载它 - https://github.com/scala-eveapi/postgres-sde/commit/95d2ed70dff8326c9acc75c56c9a7b8c8f6bbc73 - docker build正常工作。运行时,它恢复了数据库,但在运行.sql后,它只是退出,而不是保持postgres服务器的活着。从postgres docker容器继承 - 不保持守护进程活着?
文件:
FROM postgres:latest
ADD https://www.fuzzwork.co.uk/dump/latest/postgres-20161114-TRANQUILITY.dmp.bz2 sde.bz2
# ADD postgres-20161114-TRANQUILITY.dmp.bz2 sde.bz2
RUN bunzip2 sde.bz2
COPY load-sde.sh /docker-entrypoint-initdb.d/01-load-sde.sh
COPY add-constraints.sql /docker-entrypoint-initdb.d/02-add-constraints.sql
其他两个文件是:
#!/bin/bash
set -e
pg_restore -d "${POSTGRES_DB:-$POSTGRES_USER}" -U "$POSTGRES_USER" sde
和SQL:
alter table "mapSolarSystems"
alter column "solarSystemName" set not null;
alter table "invTypes"
alter column "typeName" set not null;
alter table "staStations"
alter column "stationName" set not null;
alter table "staStations"
alter column "solarSystemID" set not null;
日志:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ...
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
****************************************************
WARNING: No password has been set for the database.
This will allow anyone with access to the
Postgres port to access your database. In
Docker's default configuration, this is
effectively any other container on the same
system.
Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
waiting for server to start....LOG: database system was shut down at 2016-12-06 12:05:18 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
done
server started
ALTER ROLE
/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/01-load-sde.sh
ERROR: role "yaml" does not exist
STATEMENT: ALTER TABLE "agtAgentTypes" OWNER TO yaml;
[...] pg_restore errors
WARNING: errors ignored on restore: 89
您的Dockerfile中没有CMD或ENTRYPOINT,所以容器停止,这是正常的 – user2915097
您可以发布容器中的日志吗? – Yuva
发布日志。 – Reactormonk