Skip to content

ApsaraDB/polardb-pg-docker-images

Repository files navigation

PolarDB-PG Images

Runtime/Development Image

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:

Binary Image

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.

Local Instance Image

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.

Without Data Persistence

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:~$

With Data Persistence

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

Running as Daemon

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

Exposing Ports

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=#

Environment Variables

  • 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 initialization
  • POLARDB_PASSWORD: the default password to be used by POLARDB_USER or postgres

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages