In my previous post I showed how to build a docker hosting container with a Raspberry Pi 3. This time we will use our docker machine to host a PostgreSQL service for further application.
I found PostgreSQL the most suitable solution for my implementation, so first of all we start to prepare our environment.
We login to the docker host and create a persistent volume to store our database and then we create a container based on the latest postgresql image; the username is postgres and the password is set by the environment variable POSTGRES_PASSWORD.
docker volume create pg_data
docker run -d -p 5432:5432 --name postgres --restart always -v pg_data:/var/lib/postgresql/data -h postgreshost -u postgres -e POSTGRES_PASSWORD=dbpass postgres
To verify that all is running download the admin tool pgAdmin 4 available for your platform, execute it and create a connection with the credential used above.
You should see a predefined database postgres as follow.
And looking on portainer we can see the running containers
Easy enough? Next time we will start to write some code.