Hello i'm trying to create a postgres compose docker pg admin 4 and node
but I'm having difficulties and I can't create my server:
I've tried with all possible names and I don't know what I'm wrong:
my docker compose:
version: "3.7"
services:
emasa-postgres:
image: postgres
environment:
POSTGRES_PASSWORD: emasa@
POSTGRES_USER: postgres
POSTGRES_DB: emasa
volumes:
- ./pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- postgres-compose-network
web:
image: emasa-web
depends_on:
- emasa-postgres
ports:
- "4000:4000"
networks:
- postgres-compose-network
teste-pgadmin-compose:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "emasa@hotmail.com"
PGADMIN_DEFAULT_PASSWORD: "emasa"
ports:
- "16543:80"
depends_on:
- emasa-postgres
networks:
- postgres-compose-network
networks:
postgres-compose-network:
driver: bridge
DockerFile:
FROM node as builder
WORKDIR usr/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node
WORKDIR usr/app
COPY package*.json ./
RUN npm install --production
COPY --from=builder /usr/app/dist ./dist
COPY ormconfig.docker.json ./ormconfig.json
COPY .env .
expose 4000
CMD node dist/src/index.js
my orm config:
{
"type": "postgres",
"host": "db",
"port": 5432,
"username": "postgres",
"password": "emasa@",
"database": "postgres",
"synchronize": true,
"logging": false,
"entities": ["src/entity/**/*.ts"],
"migrations": ["src/migration/**/*.ts"],
"subscribers": ["src/subscriber/**/*.ts"],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
}
}
my docker-compose loggers:
Attaching to back-end_web_1, back-end_emasa-postgres_1, back-end_teste-pgadmin-compose_1
emasa-postgres_1 | The files belonging to this database system will be owned by user "postgres".
emasa-postgres_1 | This user must also own the server process.
emasa-postgres_1 |
emasa-postgres_1 | The database cluster will be initialized with locale "en_US.utf8".
emasa-postgres_1 | The default database encoding has accordingly been set to "UTF8".
emasa-postgres_1 | The default text search configuration will be set to "english".
emasa-postgres_1 |
emasa-postgres_1 | Data page checksums are disabled.
emasa-postgres_1 |
emasa-postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
emasa-postgres_1 | creating subdirectories ... ok
emasa-postgres_1 | selecting dynamic shared memory implementation ... posix
emasa-postgres_1 | selecting default max_connections ... 20
emasa-postgres_1 | selecting default shared_buffers ... 400kB
emasa-postgres_1 | selecting default time zone ... Etc/UTC
emasa-postgres_1 | creating configuration files ... ok
emasa-postgres_1 | 2020-03-17 23:48:08.890 UTC [81] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
emasa-postgres_1 | 2020-03-17 23:48:08.890 UTC [81] HINT: The server must be started by the user that owns the data directory.
emasa-postgres_1 | child process exited with exit code 1
emasa-postgres_1 | initdb: removing contents of data directory "/var/lib/postgresql/data"
emasa-postgres_1 | running bootstrap script ... web_1 | Error: getaddrinfo ENOTFOUND db
my container ls:
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a20bcd4f105 emasa-web "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:4000->4000/tcp back-end_web_1
b377e650e772 dpage/pgadmin4 "/entrypoint.sh" 14 minutes ago Up 14 minutes 443/tcp, 0.0.0.0:16543->80/tcp back-end_teste-pgadmin-compose_1
[![enter image description here][2]][2]
I've really tried with the container names:
emasa-postgres_1 emasa-postgres
and to no avail