I run postgres using docker-compose -f postgres.yml up. When I try to run pgadmin4 using docker-compose -f pgadmin4.yml up, postgres container is automatically killed.
I am new to docker and doesn't understand why is this issue happening?
postgres.yml
version: "3.7"
services:
postgres:
container_name: "postgres"
image: "postgres"
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: ****
volumes:
- maple:/var/lib/postgresql/data
volumes:
maple:
name: maple
external: true
pgadmin.yml
version: "3.7"
services:
postgres:
container_name: "pgadmin4"
image: "dpage/pgadmin4"
ports:
- "5433:80"
environment:
PGADMIN_DEFAULT_EMAIL: ******
PGADMIN_DEFAULT_PASSWORD: *****
volumes:
- pgadmin4-vol:/var/lib/pgadmin
volumes:
pgadmin4-vol:
name: pgadmin4-vol
external: true
$ docker-compose -f psql.yml up
Starting postgres ... done
Attaching to postgres
postgres |
postgres | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres |
postgres | 2020-11-27 10:18:05.635 UTC 1 LOG: starting PostgreSQL 13.0 (Debian 13.0-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
postgres | 2020-11-27 10:18:05.636 UTC 1 LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres | 2020-11-27 10:18:05.636 UTC 1 LOG: listening on IPv6 address "::", port 5432
postgres | 2020-11-27 10:18:05.639 UTC 1 LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres | 2020-11-27 10:18:05.643 UTC [24] LOG: database system was shut down at 2020-11-27 10:17:59 UTC
postgres | 2020-11-27 10:18:05.647 UTC 1 LOG: database system is ready to accept connections
postgres | 2020-11-27 10:18:11.089 UTC 1 LOG: received fast shutdown request
postgres | 2020-11-27 10:18:11.092 UTC 1 LOG: aborting any active transactions
postgres | 2020-11-27 10:18:11.099 UTC 1 LOG: background worker "logical replication launcher" (PID 30) exited with exit code 1
postgres | 2020-11-27 10:18:11.108 UTC [25] LOG: shutting down
postgres | 2020-11-27 10:18:11.127 UTC 1 LOG: database system is shut down
postgres exited with code 0
$ docker-compose -f pgadmin.yml up
Recreating postgres ... done
Attaching to pgadmin4
pgadmin4 | sudo: setrlimit(RLIMIT_CORE): Operation not permitted
pgadmin4 | [2020-11-27 10:18:13 +0000] 1 [INFO] Starting gunicorn 19.9.0
pgadmin4 | [2020-11-27 10:18:13 +0000] 1 [INFO] Listening at: http://[::]:80 (1)
pgadmin4 | [2020-11-27 10:18:13 +0000] 1 [INFO] Using worker: threads
pgadmin4 | /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
pgadmin4 | return io.open(fd, *args, **kwargs)
pgadmin4 | [2020-11-27 10:18:13 +0000] [87] [INFO] Booting worker with pid: 87
docker inpsect 69438bebc3f9 here
your services are both named postgres
so the pgadmin.yml recreates the service postgres, wich is your first database container.. as the logs are clearly showing
'Recreating postgres ... done'
take another name for the pgadmin service then postgres and it should work.
version: "3.7"
services:
pgadmin:
also docker-compose is for building stacks, if you would have done this in one compose file you would have seen the error from begin:
docker-compose.failing.yml:
version: "3.7"
services:
postgres:
container_name: "postgres"
image: "postgres"
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: test
volumes:
- maple:/var/lib/postgresql/data
postgres:
container_name: "pgadmin4"
image: "dpage/pgadmin4"
ports:
- "5433:80"
environment:
PGADMIN_DEFAULT_EMAIL: test
PGADMIN_DEFAULT_PASSWORD: test
volumes:
- pgadmin4-vol:/var/lib/pgadmin
volumes:
maple:
name: maple
external: true
pgadmin4-vol:
name: pgadmin4-vol
external: true
docker-compose.working.yml:
version: "3.7"
services:
postgres:
container_name: "postgres"
image: "postgres"
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: test
volumes:
- maple:/var/lib/postgresql/data
pgadmin:
container_name: "pgadmin4"
image: "dpage/pgadmin4"
ports:
- "5433:80"
environment:
PGADMIN_DEFAULT_EMAIL: test
PGADMIN_DEFAULT_PASSWORD: test
volumes:
- pgadmin4-vol:/var/lib/pgadmin
volumes:
maple:
name: maple
external: true
pgadmin4-vol:
name: pgadmin4-vol
external: true
Related
I was following this example and I ran into the error after docker-compose up
airflow-airflow_scheduler-1 | Error executing 'postInstallation': Failed to connect to postgres:5432 after 36 tries
airflow-airflow_scheduler-1 exited with code 1
airflow-airflow-1 | Error executing 'postInstallation': Failed to connect to postgres:5432 after 36 tries
airflow-airflow_worker-1 | Error executing 'postInstallation': Failed to connect to postgres:5432 after 36 tries
airflow-airflow-1 exited with code 1
airflow-airflow_worker-1 exited with code 1
My docker-compose.yml file looks like this:
# SPDX-License-Identifier: Apache-2.0
version: "3.7"
services:
airflow:
image: bitnami/airflow:1.10.13
ports:
- "8080:8080"
env_file:
- openlineage.env
environment:
- AIRFLOW_USERNAME=airflow
- AIRFLOW_PASSWORD=airflow
- AIRFLOW_EMAIL=airflow#example.com
- AIRFLOW_FERNET_KEY=Z2uDm0ZL60fXNkEXG8LW99Ki2zf8wkmIltaTz1iQPDU=
- AIRFLOW_DATABASE_HOST=postgres
- AIRFLOW_DATABASE_NAME=airflow
- AIRFLOW_DATABASE_USERNAME=airflow
- AIRFLOW_DATABASE_PASSWORD=airflow
- AIRFLOW_EXECUTOR=CeleryExecutor
- AIRFLOW_LOAD_EXAMPLES=no
- AIRFLOW_CONN_EXAMPLE_DB=postgres://example:example#postgres:5432/example
volumes:
- ./dags:/opt/bitnami/airflow/dags
- ${PWD}/whl:/whl
- type: bind
source: ${PWD}/requirements.txt
target: /bitnami/python/requirements.txt
airflow_scheduler:
image: bitnami/airflow-scheduler:1.10.13
env_file:
- openlineage.env
environment:
- AIRFLOW_FERNET_KEY=Z2uDm0ZL60fXNkEXG8LW99Ki2zf8wkmIltaTz1iQPDU=
- AIRFLOW_DATABASE_HOST=postgres
- AIRFLOW_DATABASE_NAME=airflow
- AIRFLOW_DATABASE_USERNAME=airflow
- AIRFLOW_DATABASE_PASSWORD=airflow
- AIRFLOW_EXECUTOR=CeleryExecutor
- AIRFLOW_LOAD_EXAMPLES=no
- AIRFLOW_CONN_EXAMPLE_DB=postgres://example:example#postgres:5432/example
volumes:
- ./dags:/opt/bitnami/airflow/dags
- ${PWD}/whl:/whl
- type: bind
source: ${PWD}/requirements.txt
target: /bitnami/python/requirements.txt
airflow_worker:
image: bitnami/airflow-worker:1.10.13
env_file:
- openlineage.env
environment:
- AIRFLOW_FERNET_KEY=Z2uDm0ZL60fXNkEXG8LW99Ki2zf8wkmIltaTz1iQPDU=
- AIRFLOW_DATABASE_HOST=postgres
- AIRFLOW_DATABASE_NAME=airflow
- AIRFLOW_DATABASE_USERNAME=airflow
- AIRFLOW_DATABASE_PASSWORD=airflow
- AIRFLOW_EXECUTOR=CeleryExecutor
- AIRFLOW_LOAD_EXAMPLES=no
- AIRFLOW_CONN_EXAMPLE_DB=postgres://example:example#postgres:5432/example
volumes:
- ./dags:/opt/bitnami/airflow/dags
- ${PWD}/whl:/whl
- type: bind
source: ${PWD}/requirements.txt
target: /bitnami/python/requirements.txt
marquez:
image: marquezproject/marquez:latest
ports:
- "5000:5000"
- "5001:5001"
volumes:
- ./docker/wait-for-it.sh:/usr/src/app/wait-for-it.sh
depends_on:
- postgres
entrypoint: ["./wait-for-it.sh", "postgres:5432", "--", "./entrypoint.sh"]
# Enables SQL statement logging (see: https://www.postgresql.org/docs/12/runtime-config-logging.html#GUC-LOG-STATEMENT)
# command: ["postgres", "-c", "log_statement=all"]
marquez_web:
image: marquezproject/marquez-web:latest
environment:
- MARQUEZ_HOST=marquez
- MARQUEZ_PORT=5000
ports:
- "3000:3000"
stdin_open: true
tty: true
depends_on:
- marquez
postgres:
image: bitnami/postgresql:12.1.0
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- AIRFLOW_USER=airflow
- AIRFLOW_PASSWORD=airflow
- AIRFLOW_DB=airflow
- MARQUEZ_USER=marquez
- MARQUEZ_PASSWORD=marquez
- MARQUEZ_DB=marquez
- EXAMPLE_USER=example
- EXAMPLE_PASSWORD=example
- EXAMPLE_DB=example
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ./docker/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
redis:
image: bitnami/redis:6.0.6
environment:
- ALLOW_EMPTY_PASSWORD=yes
What confuses me is that postgres seems to be ready according to airflow-postgres
airflow-postgres-1 | postgresql 05:58:32.34 INFO ==> Starting PostgreSQL in background...
airflow-postgres-1 | postgresql 05:58:32.46 INFO ==> Changing password of postgres
airflow-postgres-1 | postgresql 05:58:32.48 INFO ==> Configuring replication parameters
airflow-postgres-1 | postgresql 05:58:32.51 INFO ==> Configuring fsync
airflow-postgres-1 | postgresql 05:58:32.51 INFO ==> Loading custom scripts...
airflow-postgres-1 | postgresql 05:58:32.52 INFO ==> Loading user's custom files from /docker-entrypoint-initdb.d ...
airflow-postgres-1 | postgresql 05:58:32.52 INFO ==> Starting PostgreSQL in background...
airflow-postgres-1 | postgresql 05:58:32.82 INFO ==> Enabling remote connections
airflow-postgres-1 | postgresql 05:58:32.83 INFO ==> Stopping PostgreSQL...
airflow-postgres-1 | postgresql 05:58:33.84 INFO ==> ** PostgreSQL setup finished! **
airflow-postgres-1 |
airflow-postgres-1 | postgresql 05:58:33.90 INFO ==> ** Starting PostgreSQL **
airflow-postgres-1 | 2022-06-08 05:58:33.924 GMT [1] LOG: starting PostgreSQL 12.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
airflow-postgres-1 | 2022-06-08 05:58:33.924 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
airflow-postgres-1 | 2022-06-08 05:58:33.924 GMT [1] LOG: listening on IPv6 address "::", port 5432
airflow-postgres-1 | 2022-06-08 05:58:33.931 GMT [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
airflow-postgres-1 | 2022-06-08 05:58:33.947 GMT [216] LOG: database system was shut down at 2022-06-08 05:58:32 GMT
airflow-postgres-1 | 2022-06-08 05:58:33.957 GMT [1] LOG: database system is ready to accept connections
But it seems like airflow-marquez simply can't connect to it:
airflow-marquez-1 | wait-for-it.sh: timeout occurred after waiting 15 seconds for postgres:5432
airflow-marquez-1 | WARNING 'MARQUEZ_CONFIG' not set, using development configuration.
I'm on Linux Manjaro.
I'm very new to docker and maybe I haven't included enough information for my problem, please point that out if it's true and I'll include more information.
Thanks in advance!
I want to run my app on my local machine within Docker. I don't want to optimize the size of my docker app or build it for production now.
Docker builds my backend-api app and postgres-db successfully. But I can only access the docker postgres database outside my docker e.g. with dbeaver installed on my computer. Also if I start my backend-api app WITHOUT Docker with "npm run start", my app can also access the database without any errors and can also write into the posgres db. Only when I build the backend-api with Docker and launch the app inside the Docker, I get this error. Since this only happens within Docker, I assume that something important is missing in my Dockerfile.
My docker-compose.yml:
version: '3'
services:
backend:
build: .
container_name: backend-api
command: npm run start
restart: unless-stopped
ports:
- 3000:3000
volumes:
- .:/usr/src/backend
networks:
- docker-network
depends_on:
- database
database:
image: postgres:latest
container_name: backend-db
ports:
- 5432:5432
volumes:
- postgresdb/:/var/lib/postgresql/data/
networks:
- docker-network
environment:
POSTGRES_USER: devuser
POSTGRES_PASSWORD: devpw
POSTGRES_DB: devdb
volumes:
postgresdb:
networks:
docker-network:
driver: bridge
My Dockerfile:
FROM node:16.15.0-alpine
WORKDIR /usr/src/backend
COPY . .
RUN npm install
sudo docker-compose up --build output:
Starting backend-db ... done
Recreating backend-api ... done
Attaching to backend-db, backend-api
backend-db |
backend-db | PostgreSQL Database directory appears to contain a database; Skipping initialization
backend-db |
backend-db | 2022-05-03 20:35:46.065 UTC [1] LOG: starting PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
backend-db | 2022-05-03 20:35:46.066 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
backend-db | 2022-05-03 20:35:46.066 UTC [1] LOG: listening on IPv6 address "::", port 5432
backend-db | 2022-05-03 20:35:46.067 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
backend-db | 2022-05-03 20:35:46.071 UTC [26] LOG: database system was shut down at 2022-05-03 20:35:02 UTC
backend-db | 2022-05-03 20:35:46.077 UTC [1] LOG: database system is ready to accept connections
backend-api |
backend-api | > backend#0.0.1 start
backend-api | > nodemon
backend-api |
backend-api | [nodemon] 2.0.15
backend-api | [nodemon] to restart at any time, enter `rs`
backend-api | [nodemon] watching path(s): src/**/*
backend-api | [nodemon] watching extensions: ts
backend-api | [nodemon] starting `IS_TS_NODE=true ts-node -r tsconfig-paths/register src/main.ts`
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM LOG [NestFactory] Starting Nest application...
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM LOG [InstanceLoader] TypeOrmModule dependencies initialized +73ms
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +1ms
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM LOG [InstanceLoader] ConfigModule dependencies initialized +1ms
backend-api | [Nest] 30 - 05/03/2022, 8:35:50 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
backend-api | Error: connect ECONNREFUSED 127.0.0.1:5432
backend-api | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
backend-api | [Nest] 30 - 05/03/2022, 8:35:53 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)...
My ormconfig.ts:
import { ConnectionOptions } from 'typeorm';
const config: ConnectionOptions = {
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'devuser',
password: 'devpw',
database: 'devdb',
entities: [__dirname + '/**/*.entity{.ts,.js}'],
synchronize: false,
migrations: [__dirname + '/**/migrations/**/*{.ts,.js}'],
cli: {
migrationsDir: 'src/migrations',
},
};
export default config;
Please let me know what other information you would like me to provide. I'm new to the Docker world.
When you run a docker container localhost results in the container's localhost, not your machine's, so it's not the right host to use. As you're using docker-compose, a docker network is automatically created using the service's names as hosts. So instead of using localhost for you database host, you can use database as the host, and now the docker network will route the request properly to the database service as defined in your docker-compose.yml file
Ran into the same issue and this docker-compose.yml setup worked for me
version: "3.8"
services:
database:
container_name: db
image: postgres:14.2
ports:
- "5432:5432"
environment:
- POSTGRES_HOST_AUTH_METHOD
backend:
container_name: api
build:
dockerfile: Dockerfile
context: .
restart: on-failure
depends_on:
- database
ports:
- "3000:3000"
environment:
- DATABASE_HOST=database
- DATABASE_PORT=5432
- DATABASE_USER=postgres
- DATABASE_PASSWORD
- DATABASE_NAME
- DATABASE_SYNCHRONIZE
- NODE_ENV
Following were two main notable changes
changed the host to database so the docker network will route the
request properly to the database service as defined in your
docker-compose.yml file.
added a user postgres as default
PostgreSQL user
I am running airflow locally based on dockerfile, .env, docker-compose.yaml and entrypoint.sh
as "docker-compose -f docker-compose.yaml up"
And just after "airflow init db" in entrypoint.sh I am getting the following error:
[after it all is cool, I can run airflow. But this drives me crazy. Can anyone help me to resolve it, please?]
what's strange is that service queries the tables even before the db has been initiated
airflow_webserver | initiating db
airflow_webserver | DB: postgresql://airflow:***#airflow_metadb:5432/airflow
airflow_webserver | [2022-02-22 13:52:26,318] {db.py:929} INFO - Dropping tables that exist
airflow_webserver | [2022-02-22 13:52:26,570] {migration.py:201} INFO - Context impl PostgresqlImpl.
airflow_webserver | [2022-02-22 13:52:26,570] {migration.py:204} INFO - Will assume transactional DDL.
airflow_metadb | 2022-02-22 13:52:26.712 UTC [71] ERROR: relation "connection" does not exist at character 55
airflow_metadb | 2022-02-22 13:52:26.712 UTC [71] STATEMENT: SELECT connection.conn_id AS connection_conn_id
airflow_metadb | FROM connection GROUP BY connection.conn_id
airflow_metadb | HAVING count(*) > 1
airflow_metadb | 2022-02-22 13:52:26.714 UTC [72] ERROR: relation "connection" does not exist at character 55
airflow_metadb | 2022-02-22 13:52:26.714 UTC [72] STATEMENT: SELECT connection.conn_id AS connection_conn_id
airflow_metadb | FROM connection
airflow_metadb | WHERE connection.conn_type IS NULL
airflow_webserver | [2022-02-22 13:52:26,733] {db.py:921} INFO - Creating tables
airflow 2.2.3
postgres 13
in dockerfile:
ENTRYPOINT ["/entrypoint.sh"]
in docker-compose.yaml:
webserver:
env_file: ./.env
image: airflow
container_name: airflow_webserver
restart: always
depends_on:
- postgres
environment:
<<: *env_common
AIRFLOW__CORE__LOAD_EXAMPLES: ${AIRFLOW__CORE__LOAD_EXAMPLES}
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: ${AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION}
EXECUTOR: ${EXECUTOR}
_AIRFLOW_DB_UPGRADE: ${_AIRFLOW_DB_UPGRADE}
_AIRFLOW_WWW_USER_CREATE: ${_AIRFLOW_WWW_USER_CREATE}
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD}
_AIRFLOW_WWW_USER_ROLE: ${_AIRFLOW_WWW_USER_ROLE}
_AIRFLOW_WWW_USER_EMAIL: ${_AIRFLOW_WWW_USER_EMAIL}
logging:
options:
max-size: 10m
max-file: "3"
volumes:
- ./dags:bla-bla
- ./logs:bla-bla
ports:
- ${AIRFLOW_WEBSERVER_PORT}:${AIRFLOW_WEBSERVER_PORT}
command: webserver
healthcheck:
test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
interval: 30s
timeout: 30s
retries: 3
I am trying to connect to a Postgres database in a separate container from another separate container that stores a Go server:
Pool, err = pgxpool.Connect(context.Background(),"postgres://postgres:postgres#postgres:5432/postgres")
After doing so, I receive the following error:
2020/09/25 13:40:08 failed to connect to `host=postgres user=postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.65.1:53: no such host)
Here is the docker-compose.yml:
version: "3.8"
services:
postgres:
image: postgres:alpine
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- 5432:5432
restart: always
server:
build: .
depends_on:
- postgres
ports:
- "2302:2302"
- "80:80"
restart: always
I am successfully able to connect to the Postgres database from my OS. Here are the Postgres container initialization logs:
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2020-09-25 15:37:50.529 UTC [1] LOG: starting PostgreSQL 13.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
postgres_1 | 2020-09-25 15:37:50.529 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2020-09-25 15:37:50.529 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2020-09-25 15:37:50.532 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2020-09-25 15:37:50.536 UTC [20] LOG: database system was shut down at 2020-09-25 15:37:49 UTC
postgres_1 | 2020-09-25 15:37:50.540 UTC [1] LOG: database system is ready to accept connections
Any clues would be helpful. Thank you in advance.
Try to share a network
version: "3.8"
services:
postgres:
image: postgres:alpine
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- 5432:5432
restart: always
networks: [ "go_develop" ]
server:
build: .
depends_on:
- postgres
ports:
- "2302:2302"
- "80:80"
restart: always
networks: [ "go_develop" ]
networks:
go_develop:
driver: bridge
I recently had to restart my machine, thus shut down my docker container and server connections. After restart PGAdmin4 no longer shows docker volume data, however my application is still able to access the docker volume data. I'm able to log in to my db as user postgres, though no tables show in the db. PGAdmin4 on 5050:5050, Postgres on 5432:5432, app on 5000:5000. I'm able to log into the db via PGAdmin while the container is paused, which wasn't the case before, finding it hard to understand why.
I've got a docker-compose file like so:
version: "3.7"
services:
postgres:
container_name: postgres
restart: always
image: postgres:12.2
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- flask-app-db:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
- pgnetwork
pgadmin4:
container_name: pgadmin4
restart: always
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
- SERVER_PORT=${SERVER_PORT}
volumes:
- pga4:/var/lib/pgadmin
ports:
- 5050:5050
networks:
- pgnetwork
dplio:
container_name: dplio
restart: always
build:
context: .
dockerfile: Dockerfile
environment:
# MY_ENV_VARS
ports:
- 5000:5000
volumes:
- .:/dplio
networks:
- pgnetwork
depends_on:
- postgres
networks:
pgnetwork:
driver: bridge
volumes:
flask-app-db:
name: flask-app-db
pga4:
name: pga4
My terminal output when the containers are run:
Starting postgres ... done
Starting pgadmin4 ... done
Starting dplio ... done
Attaching to pgadmin4, postgres, dplio
postgres |
postgres | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres |
postgres | 2020-03-17 11:18:55.599 UTC [1] LOG: starting PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
postgres | 2020-03-17 11:18:55.599 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres | 2020-03-17 11:18:55.600 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres | 2020-03-17 11:18:55.604 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres | 2020-03-17 11:18:55.619 UTC [26] LOG: database system was shut down at 2020-03-17 10:41:43 UTC
postgres | 2020-03-17 11:18:55.623 UTC [1] LOG: database system is ready to accept connections
pgadmin4 | [2020-03-17 11:18:56 +0000] [1] [INFO] Starting gunicorn 19.9.0
pgadmin4 | [2020-03-17 11:18:56 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
pgadmin4 | [2020-03-17 11:18:56 +0000] [1] [INFO] Using worker: threads
pgadmin4 | [2020-03-17 11:18:56 +0000] [80] [INFO] Booting worker with pid: 80
dplio | * Serving Flask app "app" (lazy loading)
dplio | * Environment: docker
dplio | * Debug mode: on
dplio | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
dplio | * Restarting with stat
dplio | * Debugger is active!
dplio | * Debugger PIN: 209-285-043
I thought to try a pg_restore from the docker volume to host but that doesn't seem to make sense as a potential solution, I think it's a connection issue between the docker container and my host machine, not a data loss problem.
I set PGAdmin4 port to 5050 in the browser, though it worked fine without that before I restarted.
I tried visiting http://localhost:5050/?key=xxxxxxx http://0.0.0.0:5050/?key=xxxxxxx and http://1270.0.0.1:5050/?key=xxxxxxx, the key taken from ~/.pgAdmin4.XXXXXXXXXXXXXXXXXX.addr same issue.
I've tried removing my docker app image and rebuilding it, too.
Can anyone let me know what I'm missing? A step by step for shutting down server/container/network connections and restarting would be super helpful!
If you need more info let me know.
Thanks!