Docker Lab 1 : Python Application Deployment using Docker
Pre-requisites :
Install docker
- Install docker compose
Steps to setup pre-requisites :
- sudo apt-get update
- sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
- sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
- sudo apt-get install docker-ce docker-ce-cli containerd.io
- docker -version
- docker
- clear
- apt install docker-compose
- docker-compose –version
Steps to deploy application
Create a folder ——————————– DONE
Create required files under above folder
- App.py
- Dockerfile
- compose.yaml file
- requirements file
- Run “docker-compose up” command (with this command we can check the log)
Result :
Below two docker containers will be deployed
Python Application
Redis database container
We should be able to browse the application using publicIP:port or localhost:port
in the web application, we can see the no of hits or count incrementing for every hit along with the IP address from which hit occurred.
Useful commands:
root@22fa3c5b802c:~# docker network ls NETWORK ID NAME DRIVER SCOPE b0a3f811c870 bridge bridge local 65149a90b8b4 host host local 993d7d7676b8 kind bridge local aab2bdd65a7a none null local effd765af591 prometheus-grafana_default bridge local cdc2d980e45e sree_mfhnetwork bridge local
root@22fa3c5b802c:/home/sree# docker-compose down Stopping sree_web_1 ... done Stopping sree_redis_1 ... done Removing sree_web_1 ... done Removing sree_redis_1 ... done Removing network sree_mfhnetwork
Action Items:
What is flask library in Python does – c o Kaushal
From which version of Docker did “docker container” deprecated – c o Shankar
Next Step:
Deploy above application in Kubernetes
Deploy sonarqube using docker
Deploy sonarqube using K8s
Extras :
Setting up authentication to Github