polardb/polardb_pg_devel
provides runtime environment and compilation dependencies for PolarDB-PG. According to the base OS being used, it includes following tags:
ubuntu22.04
(latest
): useubuntu:22.04
as base OSubuntu20.04
: useubuntu:20.04
as base OScentos7
(DEPRECATED): usecentos:centos7
as base OS
polardb/polardb_pg_binary
is based on polardb/polardb_pg_devel:latest
, providing latest binary built from stable branch of PolarDB-PG. This image is enough for running PolarDB-PG.
polardb/polardb_pg_local_instance
is based on polardb/polardb_pg_binary:latest
, 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 psql
...
psql (11.9)
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 \
bash
...
postgres@f9b569fed05b:~$
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 \
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
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
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
$ ...
$ psql -h 127.0.0.1 -p 5432 -U postgres
psql (11.9)
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