8 July 2023
Translated with www.DeepL.com/Translator
The PostgreSQL database is an open source object-relational database system. PostgreSQL has a graphical user interface (GUI) administration control for database administration called pgAdmin. pgAdmin is a design and management interface for the PostgreSQL database. Simple operations, datasheets and databases can be performed with pgAdmin by interacting with the local file system of the database allowed by the user.
Docker will be the tool that will help us to run these two services easily and quickly, with data persistence. This way we will have an environment ready in a few minutes to continue working.
Requires docker installed
Create a folder in your project directory and inside it a
docker-compose.yml file with the following content:
version: '3.8' services: db: container_name: pg_container image: postgres restart: always environment: POSTGRES_USER: admin POSTGRES_PASSWORD: admin POSTGRES_DB: my_db PGDATA: /var/lib/postgresql/data ports: - 5432:5432 volumes: - pgdata:/var/lib/postgresql/data pgadmin: container_name: pgadmin4_container image: dpage/pgadmin4 restart: always environment: PGADMIN_DEFAULT_EMAIL: [email protected] PGADMIN_DEFAULT_PASSWORD: admin ports: - "5050:80" volumes: - pgadmin-data:/var/lib/pgadmin volumes: pgdata: pgadmin-data:
Save the changes and then raise the containers with the following command:
docker compose up
If you want to leave the containers running in the background don’t forget the
-d flag. You will be able to access pgAdmin in your browser at
And that’s it. Important: You can use whatever credentials you want as long as it is a local development environment and do not pretend to use this definition of docker compose in a productive environment.