Docker : Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers.
PostgreSQL: PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
docker ps
Now you can see your docker container id like this :
lets go inside docker as a bash shell
docker exec -it <CONTAINER ID> bash
docker exec -it d909cca76479 bash
Lets first, create database
create database newdb;
create user with password
create user newuser with encrypted password 'mynewpassword';
add user to database
grant all privileges on database newdb to newuser;
4. Backup and Restore are same you just need to change " > " direction for backup and " < " for restore.
pg_dump -C -h [Hostname] -d [dbname] -p [port] -U [username] -W > backup.sql
cat backup.sql | docker exec -i <CONTAINER ID> psql -U newuser newdb
That's how simple it is to manage postgres in docker!
Cascading style sheets only
Search engine optimization
wordpress, drupal, jumla, magento and more