Docker is an open-source platform where we can create, deploy, and run applications by using containers. Docker is similar to virtual machines (VM), but in VM you need to create a virtual operating system, while Docker allows applications to use the system kernel.
PostgreSQL community supports (v9.4,v9.5, v9.6, v10, v11 etc.) Images.
The difference between Images and containers is that Images are simply templates of instructions, and an instance of an Image is called a container.
A step-by-step guide to deploying a PostgreSQL Image on Docker using CentOS 7 64-bit machine
1. Go to https://hub.docker.com.
2. Create an account
After pressing Continue, it will ask you for your first name, last name, and some related personal questions. Press Continue, and it will then ask you to check your inbox and verify your email address. Once you’ve done that, congrats! You are registered on the site, and your DockerID is created.
3. Sign in to your account:
4. Before proceeding, you need to install Docker on your machine if it is not installed locally on your Centos
5. To install Docker Enterprise (EE), please follow this link:
Otherwise, just install Docker Community Edition (CE) by using the yum command:
6. Open a command-line terminal and start the Docker daemon service:
7. Go to https://hub.docker.com and search for 'postgres’ :
8. All the PostgreSQL server Official Images can be found there. On the right-hand side of the page, there is a command to pull the Image: "docker pull postgres." Copy it.
9. Open a command line terminal and paste the command "docker pull postgres":
10. If you want PostgreSQL v11.5, then you need to specify the tag explicitly:
Currently, 11.5 is the latest version, so both commands will pull the same Image.
11. Enter the command "docker run," which is used to launch container:
12. Run the command "docker ps" to show the status of the container and all required information:
13. Run the command "docker exec" to log in to the container:
Here you are able to log in not only to the container but also to the PostgreSQL v11.5 server.
14. Remove the container once you are done!