Docker
I have been developing projects related to Augmented Intelligence as well as updating some of them on Github. As the projects on Python involves several different libraries therefore, we tend to practice separate virtual environments that assist to manage the cluster. However, this gets cumbersome for people as they have to clone the repository, create a virtual environment, and then test the project. Somehow they may find their system does require more built-in packages. The whole process to have a working application takes a prolonged time. Docker containers are way better than setting up multiple Virtual Machines.
Read: Virtual Machines Vs Containers
The Android projects can provide a .apk, the python can provide executables too. but, they can fail on the OS side. So, Docker containers have built-in Linux os. Also, the Docker images and containers help in easy deployment to the web. Therefore, its good to have a public docker image on the Docker hub repository for easy hosting on the web services. Additionally, encouraging everyone to set up projects in minutes.
I spent a few hours learning docker from this youtube playlist. Plus, read the following two blogs:-
- Docker best practices for Data Scientists.
- How docker can help you become a more effective Data Scientist?
I started creating my existing Django project's docker image via Dockerfile.
The main concepts involving Dockerfile are:-
- Adopting the right light base image,
- Copying the source code,
- Changing the working directory,
- Installing the necessary packages and libraries with no cache and trusted resource,
- Mounting the host folder through volume,
- Some initial environment variables such as PYTHONUNBUFFERED=1 which allows for log messages to be immediately dumped to the stream instead of being buffered.
- Exposing the ports,
- CMD for specific commands,
- At last, having an entry point startup file (.sh).
Did you know Docker images are immutable?
They are read-only containers. ORM-based Django has an inbuilt SQLite database for storing data and authentication. Docker-compose yaml/yml file creates a multi-container app by sharing OS kernel and communication to DB through different open ports and mounting a host directory through volumes to save the modifications.
Next, I've been trying to deploy the docker image on the Azure web app service. And, there's probably something I'm doing wrong. Maybe creating Container Instances would solve. Also, I would learn to configure NGINX as a webserver.
If you're an experienced Docker user please get in touch. Others let me know your views in the comments.