...
create a new folder: database_postgres
create a new text file inside the folder called: docker-compose.yml
add this code snipped into the file …
Code Block |
---|
version: '3'
services:
postgres:
image: postgres:14.4
restart: always
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
volumes:
- ./postgres-data:/var/lib/postgresql/data |
...
Code Block |
---|
docker-compose up -d |
...
This example script will create Docker Compose for Postgres & pgAdmin
Please make sure to update marked:{CHANGE HERE}
Code Block | ||
---|---|---|
| ||
version: '3.5'
services:
postgres:
container_name: postgres_container
image: postgres
environment:
POSTGRES_USER: {CHANGE HERE}
POSTGRES_PASSWORD: {CHANGE HERE}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: {CHANGE HERE}
PGADMIN_DEFAULT_PASSWORD: {CHANGE HERE}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/root/.pgadmin
ports:
- "6060:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:
|
Run this command to start the database:
Code Block |
---|
docker-compose up -d |
After installation you can access pgAdmin via port 6060
to manage the database.
In a web browser navigate to: http://my-server:6060
Configure Postgres Server
...