Docker trusted build for PostgreSQL database
PostgreSQL v9.3.3
$ git clone [email protected]:jllopis/docker-postgresql.git
$ cd docker-postgresql
$ docker build --rm -t my_user/postgresql:latest
# docker run -d -p 5432:5432 \
-v {local_etc_fs}:/etc/postgresql \
-v {local_log_fs}:/var/log/postgresql \
-v {local_lib_fs}:/var/lib/postgresql \
-t -h {node_host_name} -name {image_name} my_user/postgresql:latest
where:
You can also start postgresql image with command line options:
# docker run -d -p 7777:7777 \
-v {local_etc_fs}:/etc/postgresql \
-v {local_log_fs}:/var/log/postgresql \
-v {local_lib_fs}:/var/lib/postgresql \
-t -h {node_host_name} -name {image_name} \
my_user/postgresql:latest -c config_file=/etc/postgresql/other_postgresql.conf
The ports used are:
Remember that if you want access from outside the container you must explicitly tell docker to do so by setting -p at image launch.
By default, a postgres user is created and given a password (default password: secret). It is highly encouraged that you change this password for your own.
To change the password issue:
psql --command "ALTER USER postgres ENCRYPTED PASSWORD 'secret';"
Change 'secret' for your highly secure password.
Usually you can modify the database (manage users, databases, etc) by executing psql commands from your host by way of the postgres user:
psql -Upostgres --command "SQL COMMAND;"
psql -Upostgres --command "CREATE ROLE my_user WITH LOGIN ENCRYPTED PASSWORD 'very_secure_password';"
psql -Upostgres --command "CREATE DATABASE testdb OWNER my_user ENCODING 'UTF-8';"
psql -Upostgres --command "DROP DATABASE testdb;"
$ psql -Upostgres < path_to_dump_file.sql
Content type
Image
Digest
sha256:77c34e7fc…
Size
97.4 MB
Last updated
almost 11 years ago
docker pull jllopis/postgresql:9.3.3