Qual é a sua dúvida?
Docker-compose PostgreSQL 11, PostgreSQL13 e PgAdmin4 para ambiente de desenvolvimento e testes
Crie o arquivo docker-compose.yml em uma pasta de sua preferência
$ mkdir /opt/dockers/postgres-dev
$ cd /opt/dockers/postgres-dev
$ nano docker-compose.yml
Insira o conteúdo abaixo
version: '3'
services:
postgresdb:
container_name: postgres
image: postgres:13
environment:
POSTGRES_PASSWORD: "docker"
ports:
- "15432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
- postgres-conf:/var/lib/postgresql/
networks:
postgres-network:
ipv4_address: 172.50.50.105
postgres11:
container_name: postgres11
image: postgres:11
environment:
POSTGRES_PASSWORD: "docker"
ports:
- "15411:5432"
volumes:
- postgres11-data:/var/lib/postgresql/data
- postgres11-conf:/var/lib/postgresql/
networks:
postgres-network:
ipv4_address: 172.50.50.115
pgadmin4:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "fabriciojf@gmail.com"
PGADMIN_DEFAULT_PASSWORD: "docker"
ports:
- "16543:80"
volumes:
- pgadmin-data:/var/lib/pgadmin
depends_on:
- postgresdb
networks:
postgres-network:
ipv4_address: 172.50.50.110
networks:
postgres-network:
external:
name: devnetwork
volumes:
postgres-data:
postgres-conf:
postgres11-data:
postgres11-conf:
pgadmin-data:
Utilizando a imagem
Subindo o serviço
Na pasta que contém o docker-compose.yml do postgres e execute o comando:
docker-compose up -d
Derrubando o serviço
Na pasta que contém o docker-compose.yml do postgres e execute o comando:
docker-compose down
PgAdmin Login Data
Para login no PgAdmin4 ajuste essas configurações dentro do docker-compose.yml, o default é:
- url: http://localhost:16543
- email: fabriciojf@gmail.com
- pass: docker
Registrando um Server do docker no PgAdmin4
- Botão direiro em Servers > Create > Server
- Aba General
- Name: postgres11
- Aba Connection
-
Host name/address: Digite o nome do serviço postgres criado no docker. Ex:
version: '3'
services:
postgresdb: <=====
container_name: postgres - Host name/address: postgresdb
- Port: 5432
- Username: postgres
- Quando for solicitado a senha digite docker
-