I am going to build a PostGIS database server for my GIS datasets. And I want to build it on top of Fedora 28. Rather than to install directly on my Fedora 28 host, I prefer to use the Docker container. So, this article is going to show you the steps to Install PostgreSQL Docker Containers on Fedora 28. There are some reasons why I decide to use Docker containers. I hope this article will be useful for you who looking for a simple way to deploy PostgreSQL server on Fedora 28. You may want to read some great PostgreSQL Tutorials before you continue.
What will be in this article
- Run PostgreSQL Server container
- Connect to PostgreSQL using PgAdmin 4
- Create a new Database and user
Steps to Install PostgreSQL Docker Containers on Fedora 28
Step 1. Install Docker
First, we need to install Docker on Fedora 28. Please refers to my previous article to install Docker CE on Fedora 28. This is a good article to get started. After installing Docker, now we can deploy a new PostgreSQL container.
Step 2. Run PostgreSQL Container
In Terminal, copy and paste this command to deploy PostgreSQL container
docker run --name postgresql01 --restart=always -e POSTGRES_PASSWORD=12345 -p 54320:5432 -d postgres
Please change the following:
- postgresql01 — change it with your own name
- 12345 — change it with your password for postgres superuser
- 54320 — change it to other port if you want. You can also use the default PostgreSQL port which is 5432.
Now Docker will download Postgres image from the internet if you don’t have it locally. After the process is completed, check if our new PostgreSQL container is up and running.
Step 3. Connect to the PostgreSQL Container
Open PgAdmin 4 from other computer or from Fedora. On this example, I connect to my PostgreSQL server from Windows PC via PgAdmin. You need to install PgAdmin if you don’t have it. Open PgAdmin 4 and click Add New Server
Enter the IP address of your Docker host, the port, username and password of the PostgreSQL container we created earlier. Hit Save.
Step 4. Create a New Database/Schema
Now, we can continue to create a new database or schema from PgAdmin 4. To create a new database, go to Object | Create | Database.