polardb/polardb_pg_devel:${tag}
provides runtime environment and compilation dependencies for PolarDB-PG. According to the base OS being used, it includes following tags:
ubuntu24.04
: useubuntu:24.04
as base OSubuntu22.04
: useubuntu:22.04
as base OSubuntu20.04
: useubuntu:20.04
as base OSrocky9
: userockylinux:9
as base OSrocky8
: userockylinux:8
as base OSanolis8
: useopenanolis/anolisos:8.6
as base OScentos7
(DEPRECATED): usecentos:centos7
as base OS
polardb/polardb_pg_binary:${tag}
is based on polardb/polardb_pg_devel:22.04
, providing latest binary built from stable branch of PolarDB-PG. This image is enough for running PolarDB-PG.
polardb/polardb_pg_local_instance:${tag}
is based on polardb/polardb_pg_binary:${tag}
, with an entrypoint for initializing and starting-up PolarDB-PG instance on local file system.
Simply try without persisting data directories. It will initialize database inside the container and start the database up. Override Docker CMD
of image with psql
to connect to the database:
$ docker run -it --rm polardb/polardb_pg_local_instance:15 psql
...
psql (PostgreSQL 15.8 (PolarDB 15.8.2.0 build unknown) on x86_64-linux-gnu)
Type "help" for help.
postgres=#
If you don't want to get into psql
, simply override Docker CMD
with other command:
$ docker run -it --rm \
polardb/polardb_pg_local_instance:15 \
bash
...
postgres@876f3bc68b4e:~$
Use an empty local directory as a volume, and mount the volume when creating the container. The container entry point will try to initdb in this volume. ${your_data_dir}
should be empty for the first time. If the volume is not empty, the entry point will regard the volume as already been initialized, and will start-up the database instance from the volume. The volume must be mounted under /var/polardb/
inside container:
docker run -it --rm \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance:15 \
psql
For those who want to use PolarDB-PG as a daemon service, the container can be created with -d
option:
docker run -d \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance:15
For those who want to export ports to host machine, use POLARDB_PORT
environment variable to specify ports. Typically, PolarDB-PG needs three continuous unused ports. Use -p
option to expose these ports, e.g. 5432-5434
:
docker run -d \
--env POLARDB_PORT=5432 \
-p 5432-5434:5432-5434 \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance:15
Or directly use --network=host
to share network with host machine:
$ docker run -d \
--network=host \
--env POLARDB_PORT=5432 \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance:15
$ ...
$ psql -h 127.0.0.1 -p 5432 -U postgres
psql (PostgreSQL 15.8 (PolarDB 15.8.2.0 build unknown) on x86_64-linux-gnu)
Type "help" for help.
postgres=#
POLARDB_PORT
: the port on which primary node will be running; two replica nodes will be running at${POLARDB_PORT}+1
and${POLARDB_PORT}+2
POLARDB_USER
: the default superuser to be created during initializationPOLARDB_PASSWORD
: the default password to be used byPOLARDB_USER
orpostgres