2016-05-16 23 views
5

Postgres tắt ngay lập tức khi bắt đầu với trình tạo docker. Các tập tin yaml sử dụng dướiPostgres tắt ngay lập tức khi bắt đầu với docker-compose

version: '2' 

services: 
    postgres: 
     image: postgres:9.5 
     container_name: local-postgres9.5 
     ports: 
      - "5432:5432" 

Nhật ký khi Docker-soạn lên lệnh được thực thi

Creating local-postgres9.5 
Attaching to local-postgres9.5 
local-postgres9.5 | The files belonging to this database system will be owned by user "postgres". 
local-postgres9.5 | This user must also own the server process. 
local-postgres9.5 | 
local-postgres9.5 | The database cluster will be initialized with locale "en_US.utf8". 
local-postgres9.5 | The default database encoding has accordingly been set to "UTF8". 
local-postgres9.5 | The default text search configuration will be set to "english". 
local-postgres9.5 | 
local-postgres9.5 | Data page checksums are disabled. 
local-postgres9.5 | 
local-postgres9.5 | fixing permissions on existing directory /var/lib/postgresql/data ... ok 
local-postgres9.5 | creating subdirectories ... ok 
local-postgres9.5 | selecting default max_connections ... 100 
local-postgres9.5 | selecting default shared_buffers ... 128MB 
local-postgres9.5 | selecting dynamic shared memory implementation ... posix 
local-postgres9.5 | creating configuration files ... ok 
local-postgres9.5 | creating template1 database in /var/lib/postgresql/data/base/1 ... ok 
local-postgres9.5 | initializing pg_authid ... ok 
local-postgres9.5 | initializing dependencies ... ok 
local-postgres9.5 | creating system views ... ok 
local-postgres9.5 | loading system objects' descriptions ... ok 
local-postgres9.5 | creating collations ... ok 
local-postgres9.5 | creating conversions ... ok 
local-postgres9.5 | creating dictionaries ... ok 
local-postgres9.5 | setting privileges on built-in objects ... ok 
local-postgres9.5 | creating information schema ... ok 
local-postgres9.5 | loading PL/pgSQL server-side language ... ok 
local-postgres9.5 | vacuuming database template1 ... ok 
local-postgres9.5 | copying template1 to template0 ... ok 
local-postgres9.5 | copying template1 to postgres ... ok 
local-postgres9.5 | syncing data to disk ... ok 
local-postgres9.5 | 
local-postgres9.5 | WARNING: enabling "trust" authentication for local connections 
local-postgres9.5 | You can change this by editing pg_hba.conf or using the option -A, or 
local-postgres9.5 | --auth-local and --auth-host, the next time you run initdb. 
local-postgres9.5 | 
local-postgres9.5 | Success. You can now start the database server using: 
local-postgres9.5 | 
local-postgres9.5 |  pg_ctl -D /var/lib/postgresql/data -l logfile start 
local-postgres9.5 | 
local-postgres9.5 | **************************************************** 
local-postgres9.5 | WARNING: No password has been set for the database. 
local-postgres9.5 |   This will allow anyone with access to the 
local-postgres9.5 |   Postgres port to access your database. In 
local-postgres9.5 |   Docker's default configuration, this is 
local-postgres9.5 |   effectively any other container on the same 
local-postgres9.5 |   system. 
local-postgres9.5 | 
local-postgres9.5 |   Use "-e POSTGRES_PASSWORD=password" to set 
local-postgres9.5 |   it in "docker run". 
local-postgres9.5 | **************************************************** 
local-postgres9.5 | waiting for server to start....LOG: database system was shut down at 2016-05-16 16:51:54 UTC 
local-postgres9.5 | LOG: MultiXact member wraparound protections are now enabled 
local-postgres9.5 | LOG: database system is ready to accept connections 
local-postgres9.5 | LOG: autovacuum launcher started 
local-postgres9.5 | done 
local-postgres9.5 | server started 
local-postgres9.5 | ALTER ROLE 
local-postgres9.5 | 
local-postgres9.5 | 
local-postgres9.5 | /docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* 
local-postgres9.5 | 
local-postgres9.5 | LOG: received fast shutdown request 
local-postgres9.5 | LOG: aborting any active transactions 
local-postgres9.5 | LOG: autovacuum launcher shutting down 
local-postgres9.5 | LOG: shutting down 
local-postgres9.5 | waiting for server to shut down....LOG: database system is shut down 
local-postgres9.5 | done 
local-postgres9.5 | server stopped 
local-postgres9.5 | 
local-postgres9.5 | PostgreSQL init process complete; ready for start up. 
local-postgres9.5 | 
local-postgres9.5 | LOG: database system was shut down at 2016-05-16 16:51:55 UTC 
local-postgres9.5 | LOG: MultiXact member wraparound protections are now enabled 
local-postgres9.5 | LOG: database system is ready to accept connections 
local-postgres9.5 | LOG: autovacuum launcher started 

Postgres dường như làm việc tốt khi một container được bắt đầu sử dụng cùng một hình ảnh với Docker chạy

docker run --name local-postgres9.5 -p 5432:5432 postgres:9.5 
+1

nếu sự cố của bạn được giải quyết rồi chia sẻ với chúng tôi! – shuboy2014

Trả lời

1

Tôi đã cố gắng tạo docker và dịch vụ có vẻ như đang chạy trong vùng chứa:

[email protected]:/# ps aux 
USER  PID %CPU %MEM VSZ RSS TTY  STAT START TIME COMMAND 
postgres  1 0.5 0.8 227148 16128 ?  Ss 14:42 0:00 postgres 
postgres 74 0.0 0.0 227148 1768 ?  Ss 14:42 0:00 postgres: checkpointer process 
postgres 75 0.0 0.0 227148 1772 ?  Ss 14:42 0:00 postgres: writer process 
postgres 76 0.0 0.0 227148 1768 ?  Ss 14:42 0:00 postgres: wal writer process 
postgres 77 0.0 0.1 227576 2720 ?  Ss 14:42 0:00 postgres: autovacuum launcher process 
postgres 78 0.0 0.0 82132 1888 ?  Ss 14:42 0:00 postgres: stats collector process 
root  79 2.0 0.0 21820 1984 ?  Ss 14:42 0:00 /bin/bash 
root  84 0.0 0.0 19092 1296 ?  R+ 14:42 0:00 ps aux 

Dù sao, đối với dự án của tôi, tôi sử dụng một hình ảnh khác cho postgresql: https://github.com/sameersbn/docker-postgresql. Điều này hoạt động tốt.

+1

Cảm ơn. Bạn đúng postgres thực sự đang chạy. Tôi cho rằng kể từ khi docker-compose không di chuyển quá khứ lên thùng chứa postgres rằng đây là một vấn đề. Khi tôi sử dụng tùy chọn -d mọi thứ dường như hoạt động tốt. – arjunurs

3

Nếu bạn nhìn vào dữ liệu ghi nhận của bạn, những dòng sau xuất hiện phía cuối:

local-postgres9.5 | server stopped 
local-postgres9.5 | 
local-postgres9.5 | PostgreSQL init process complete; ready for start up. 

Rõ ràng, dừng lại và khởi động lại máy chủ Postgres là một phần của quá trình khởi động. Trên thực tế, dòng thứ hai đến cuối cùng cho biết

local-postgres9.5 | LOG: database system is ready to accept connections. 
Các vấn đề liên quan