Docker
Docker-compose
PostgreSQL
Adminer
Python
Pscorpg2
DockerHUB
- Pull and initiate Docker image with PostgreSQL
- Pull and initiate Docker image with Adminer
- Create Docker-compose configuration with next capability:
- Database "Northwind" have to be initiated at start to PostgreSQL
- Adminer can connect PostgreSQL and edit database inside docker container
- PostgreSQL can be reached from host IP
- Custom application have to run queri after database initialisation
- Run custom application with next task: Query how many units of products are on sale by product category in price equivalent. Show those that are more expensive than 5000
- Save image to DockerHub
-
Installing Docker infrastructure:
-
Configure Docker access:
- add docker to group
$ sudo groupadd docker
- add your user to the docker group:
$ sudo usermod -aG docker $USER
- Check if docker belongs to your user group:
$ groups
docker adm cdrom sudo dip plugdev lpadmin lxd sambashare foo
- Creating custom application: to run database queri
- Using psycorpg2 database adapter to connect app to PostgreSQL database
- Configure import requirements for custom application
- Download Northwind database sample to ./db directory
- Creating Dockerfile to configure
Docker image
run steps - Creating Docker-compose.yaml to configure
Docker container
infrastructure- setting
Postgres
configuration with initialisation.db values(Northwind will be initialised at startup of database) - setting
Adminer
configuration - setting Custom App configuration
Docker-compose
will create default network to provide connection between application. We need to specify only ports to make application available from host.
- setting
- Building image and running container with
docker-compose
:
$ docker-compose up --build
- Shutting down container:
$ docker-compose down --volumes
- Renaming image and adding version tag:
$ docker tag docker_postgres_app valknutt/docker_postgres_psycorpg2:v1.0
-
Creating repository with name docker_postgres_psycorpg2 on
DockerHUB
-
login to DockerHUB from terminal:
$ docker login --username ******** --pasword *********
$ docker push valknutt/docker_postgres_psycorpg2:v1.0
- Cleaning local Docker containers
$ docker container prune
- Cleaning local Docker images
$ docker images prune
- Delete unused images if needed
$ docker images
$ docker rmi image_id