The BEST way to setup Postgres docker container using data only container

Published: 01 November 2015
on channel: How to Linux in 60sec
6K
2

The BEST way to setup Postgres docker container using a data only container. Data only container is used to store DB data. Data will remain even if dbdata container is deleted. We use mount from dbdata inside db container.

I have used psql_client to test DB connection. It can be any container with application which is using DB.

docker search data
docker pull maxexcloo/data
docker inspect postgres
docker run --name dbdata -v /var/lib/postgresql/data maxexcloo/data
docker inspect dbdata
ls /var/lib/docker/volumes/fb0e84fd5338617110771836d155f2e7cc87d0951134e1bf9bb44db557698059/_data
docker run --name db --volumes-from dbdata -d postgres
docker ps -a
docker run --name my_app --link db:db -ti psql_client
cat /etc/hosts
psql -U -postgres -h db
create database test;
\q
exit
docker inspect dbdata
ls /var/lib/docker/volumes/fb0e84fd5338617110771836d155f2e7cc87d0951134e1bf9bb44db557698059/_data


Watch video The BEST way to setup Postgres docker container using data only container online without registration, duration 01 minute 46 second in high hd quality. This video was added by user How to Linux in 60sec 01 November 2015, don't forget to share it with your friends and acquaintances, it has been viewed on our site 6 thousand once and liked it 2 people.