РЕДАКТИРОВАТЬ: Я обнаружил проблему, согласно документации Microsoft
docs.microsoft.com / en-us / azure / app-service / Containers /…
depen_on игнорируетсяAzure Docker Compose (Preview), поэтому контейнер хоста подключается к базе данных, даже если он еще не полностью инициализирован.
Контейнер Postgres не может подключиться к контейнеру хранения, который я создал
Привет, ребята,
Я создаю образы контейнеров с помощью отдельного файла Docker и помещаю его в личный реестр, а в моем текущем файле docker-compose я его извлекаю.
для БДКонтейнер представляет собой Dockerfile
FROM postgres
# run initdb on init
COPY create.sh /docker-entrypoint-initdb.d
Я просто хотел бы спросить ваше предложение относительно текущей проблемы, которую я решаю, поэтому у меня есть этот файл .yml
services:
gateway:
container_name: gateway
image: <container-registry>/gateway
ports:
- 80:8000
webclient:
container_name: webclient
image: <container-registry>/webclient
pdf:
container_name: pdf
image: <container-registry>/reporting
test:
container_name: test
image: <container-registry>/test
db:
container_name: db
image: <container-registry>/db
storage:
container_name: storage
image: <container-registry>/storage
environment:
- PGUSER=postgres
- PGHOST=db
- PGDATABASE=postgres
- PGPASSWORD=postgres
- PGPORT=5432
depends_on:
- db
, который я использую, используяdocker-compose на лазурном, и я храню эту ошибку в своих логах
2019-09-25T11:31:05.335234931Z This user must also own the server process.
2019-09-25T11:31:05.335240831Z
2019-09-25T11:31:05.339363820Z The database cluster will be initialized with locale "en_US.utf8".
2019-09-25T11:31:05.339791719Z The default database encoding has accordingly been set to "UTF8".
2019-09-25T11:31:05.339805619Z The default text search configuration will be set to "english".
2019-09-25T11:31:05.340346817Z
2019-09-25T11:31:05.340360217Z Data page checksums are disabled.
2019-09-25T11:31:05.341061615Z
2019-09-25T11:31:05.341643014Z fixing permissions on existing directory /var/lib/postgresql/data ... ok
2019-09-25T11:31:05.344159607Z creating subdirectories ... ok
2019-09-25T11:31:05.448387934Z selecting default max_connections ... 100
2019-09-25T11:31:05.543195585Z selecting default shared_buffers ... 128MB
2019-09-25T11:31:06.229627484Z selecting default timezone ... Etc/UTC
2019-09-25T11:31:06.237649663Z selecting dynamic shared memory implementation ... posix
2019-09-25T11:31:06.241119453Z creating configuration files ... ok
2019-09-25T11:31:07.935687707Z running bootstrap script ... ok
2019-09-25T11:31:08.890002102Z performing post-bootstrap initialization ... ok
2019-09-25T11:31:10.325542035Z syncing data to disk ... ok
2019-09-25T11:31:10.326324633Z
2019-09-25T11:31:10.326341133Z WARNING: enabling "trust" authentication for local connections
2019-09-25T11:31:10.326347433Z You can change this by editing pg_hba.conf or using the option -A, or
2019-09-25T11:31:10.326352333Z --auth-local and --auth-host, the next time you run initdb.
2019-09-25T11:31:10.326377033Z
2019-09-25T11:31:10.326384733Z Success. You can now start the database server using:
2019-09-25T11:31:10.326389633Z
2019-09-25T11:31:10.328630127Z pg_ctl -D /var/lib/postgresql/data -l logfile start
2019-09-25T11:31:10.328646727Z
2019-09-25T11:31:10.333458115Z ****************************************************
2019-09-25T11:31:10.333489115Z WARNING: No password has been set for the database.
2019-09-25T11:31:10.333495915Z This will allow anyone with access to the
2019-09-25T11:31:10.333500615Z Postgres port to access your database. In
2019-09-25T11:31:10.333505315Z Docker's default configuration, this is
2019-09-25T11:31:10.333509915Z effectively any other container on the same
2019-09-25T11:31:10.333514815Z system.
2019-09-25T11:31:10.333519315Z
2019-09-25T11:31:10.333523715Z Use "-e POSTGRES_PASSWORD=password" to set
2019-09-25T11:31:10.333528315Z it in "docker run".
2019-09-25T11:31:10.333541714Z ****************************************************
2019-09-25T11:31:10.375878403Z waiting for server to start....2019-09-25 11:31:10.375 UTC [41] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-09-25T11:31:10.395690651Z 2019-09-25 11:31:10.395 UTC [42] LOG: database system was shut down at 2019-09-25 11:31:08 UTC
2019-09-25T11:31:10.402189834Z 2019-09-25 11:31:10.402 UTC [41] LOG: database system is ready to accept connections
2019-09-25T11:31:10.455505894Z done
2019-09-25T11:31:10.456282992Z server started
2019-09-25T11:31:10.457141190Z
2019-09-25T11:31:10.457927688Z /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/create.sh
2019-09-25T11:31:10.913858392Z CREATE DATABASE
2019-09-25T11:31:11.033535978Z CREATE EXTENSION
2019-09-25T11:31:04.697828703Z {"name":"AzureAD: Bearer Strategy","hostname":"<secret>","pid":1,"level":30,"msg":"In BearerStrategy constructor: strategy created","time":"2019-09-25T11:31:04.686Z","v":0}
2019-09-25T11:31:08.468063510Z (node:1) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 172.16.12.7:5432
2019-09-25T11:31:08.468093110Z at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
2019-09-25T11:31:08.470855402Z (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
2019-09-25T11:31:08.471423301Z (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2019-09-25T11:31:11.470382331Z CREATE DATABASE
2019-09-25T11:31:11.553230214Z CREATE EXTENSION
2019-09-25T11:31:11.554814910Z
2019-09-25T11:31:11.560234396Z 2019-09-25 11:31:11.560 UTC [41] LOG: received fast shutdown request
2019-09-25T11:31:11.564003086Z waiting for server to shut down....2019-09-25 11:31:11.563 UTC [41] LOG: aborting any active transactions
2019-09-25T11:31:11.572397064Z 2019-09-25 11:31:11.572 UTC [41] LOG: background worker "logical replication launcher" (PID 48) exited with exit code 1
2019-09-25T11:31:11.573542761Z 2019-09-25 11:31:11.573 UTC [43] LOG: shutting down
2019-09-25T11:31:11.595197304Z 2019-09-25 11:31:11.595 UTC [41] LOG: database system is shut down
2019-09-25T11:31:11.666505717Z done
2019-09-25T11:31:11.667496314Z server stopped
2019-09-25T11:31:11.668204112Z
2019-09-25T11:31:11.668767011Z PostgreSQL init process complete; ready for start up.
2019-09-25T11:31:11.669199010Z
2019-09-25T11:31:11.705026416Z 2019-09-25 11:31:11.704 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-09-25T11:31:11.705057116Z 2019-09-25 11:31:11.704 UTC [1] LOG: listening on IPv6 address "::", port 5432
2019-09-25T11:31:11.713025695Z 2019-09-25 11:31:11.712 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-09-25T11:31:11.789836193Z 2019-09-25 11:31:11.789 UTC [108] LOG: database system was shut down at 2019-09-25 11:31:11 UTC
2019-09-25T11:31:11.833377779Z 2019-09-25 11:31:11.822 UTC [1] LOG: database system is ready to accept connections```
Any Ideas on what I'm doing wrong? If I need to provide more files to recognize the problem just say it and I will provide :)
Thank you!