- PostgreSQL: PostgreSQL, often referred to as Postgres, is a powerful, open-source relational database management system (RDBMS). It is known for its extensibility and adherence to SQL standards, making it a robust choice for handling complex data and supporting a wide range of applications.
- pgAdmin: pgAdmin is a popular open-source administration and management tool for PostgreSQL. It provides a user-friendly interface to interact with PostgreSQL databases, allowing users to perform tasks such as creating and managing databases, executing SQL queries, and monitoring server performance.
- Docker: Docker is a platform that enables developers to automate the deployment of applications within lightweight, portable containers. Containers package an application and its dependencies, ensuring consistency across different environments. Docker simplifies the deployment process and enhances scalability and flexibility in managing applications.
- Docker Compose: Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to describe all the services, networks, and volumes required for an application in a single YAML file. With a single command, Docker Compose can then start and connect all the defined containers, streamlining the setup and management of complex applications.
- In this blog, we will discuss how to deploy PostgreSQL and pgAdmin with Docker Compose
To get started, install Docker and Docker Compose. Find detailed instructions in this link. Once this installation is complete, you’re ready to dive into the powerful features that Docker brings to the table. Get ready to explore a world of seamless containerization and efficient deployment!
Create a Docker Compose YAML file
Now, prepare yourself, and start the process by creating a new folder and navigating to it:
Create a new file named
docker-compose.yaml and use the following code
command: postgres -c 'max_connections=1000'
PGADMIN_DEFAULT_EMAIL: "[email protected]"
Adjust certain points to suit your specific situation:
After making the adjustments, save the file.
Start docker compose
Now, you simply need to run a single-line command to start both PostgreSQL and pgAdmin:
docker compose up
docker compose up -d
to start it as a daemon.
Check the results
Awesome! You can access pgAdmin using the link http://your-ip-server:8080 to get started. Login with you pgadmin email and password in
Let’s attempt to connect to PostgreSQL on port 5432
Clean up after running Docker Compose
After usage, you can tidy up by running the command
docker compose down
That is an easy and quick way to deploy PostgreSQL and pgAdmin with Docker Compose, even if you are a beginner. I hope you will succeed in deploying it. Check out other useful tips on the Toan Thien blog.