The steps to deploy a Gauss database (openGauss) to Docker are as follows:
Install Docker: If your system has not installed Docker, it needs to be installed first. Taking CentOS as an example, you can use the following command to install Docker:
yum install -y docker
Pull the mirror: Use the Docker command to pull the image of the Gaussian database. You can pull the openGauss image provided by enmotech from Docker Hub:
docker pull enmotech/opengauss:latest
Run the container: Create and start a Docker container and set the necessary environment variables. Here is a basic startup command example:
docker run --name opengauss \ --privileged=true -idt \ --restart=always \ -u root \ -p 15432:5432 \ -e GS_PASSWORD=YourPassword \ -v /etc/localtime:/etc/localtime \ -v /data/OpenGauss:/var/lib/opengauss \ enmotech/opengauss:latest
in:
-
--name opengauss
Specify the container name as opengauss. -
--privileged=true
Provides container privilege mode. -
-idt
and--restart=always
Make sure the container starts automatically after Docker restarts. -
-u root
Run as root user. -
-p 15432:5432
Map the container's port 5432 to port 15432 of the host. -
-e GS_PASSWORD=YourPassword
Set the password of the database super user Omm and test user Gaussdb. The password needs to meet the complexity requirements, that is, it is more than 8 characters in length, including English letters, numbers and special symbols. -
-v /etc/localtime:/etc/localtime
Mount time zone. -
-v /data/OpenGauss:/var/lib/opengauss
Mount data volumes for persisting database data.
Connect to use: After the container is started, you can connect to the database through port 15432 of the host. If you need to connect from outside the container, make sure that the password and port are set correctly.
Configure remote connections(If needed): If you need to connect to the database from outside the container, you may need to modify the database's configuration file to allow remote connections. This usually involves modificationand
pg_hba.conf
document. You can use the following command to enter the container and modify it:
docker exec -it opengauss sh
Then edit the configuration file:
- Revise
In the file
listen_addresses
for*
。 - Revise
pg_hba.conf
File, allowing all IP addresses to be connected using SHA256 authentication.
The above steps provide a basic guide to deploying a Gaussian database into a Docker container. The specific steps may vary depending on your Docker version and Gaussian database version. Please adjust [^1^] according to the actual situation.
This is the end of this article about how docker deploys Gaussian database. For more related content on docker deploying Gaussian database, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!