Python with Docker🐋

Gulsha Chawla
3 min readAug 24, 2021

What is Python? Why Python?

💁🏻‍♀️Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. Its latest version is Python 3.7
It is used for :
📌Web development (server-side)
📌Software development
📌Mathematics
📌System scripting.
📌Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
📌Python has a syntax that allows developers to write programs with fewer lines than some other programming languages.
📌Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
📌Python can be treated in a procedural way, an object-oriented way, or a functional way.

Task Description📃

Setting up Python Interpreter and running python code on docker container

Let’s move towards the practical part

Firstly before running docker services I will disable firewall security of base o.s using #systemctl stop firewalld & change mode of SELINUX. Here #setenforce 0 is a command which changes SELINUX from targeted to Permissive Mode. In this mode, we can perform all actions without any security issues.

Security disabled

Now we will check our docker images

Myths & Reality

Here I have a centos image that I had already installed a few hours ago, now a Myth🌀 comes in a scenario that the storage provided by docker containers is ephemeral in nature. It means docker provides us temporary storage & after each exit from o.s, we lose our data.

But here the Reality💯 is quite fishy😳actually we all think we lost our data but behind the scene, it is still there how can we check it ?? we can use #docker ps -a herein above image we can see my all last exited o.s, nowhere I got my previously used container unique id & name.

So by using #docker start os-id here I started my previous o.s simultaneously I also went inside o.s using #docker attach os-id.

Hence, we can say docker provides permanent storage of all our files, data, etc. Until we manually terminate it.

Now it’s time to set up a python interpreter so we need to install it by using the command #yum install python3

Python on top of docker successfully installed.

Let’s now run the python interpreter

Here #python3 is the command which helps the user to enter into a python interpreter.

Now we will make a python file using #vi gc.py

Python Code

Then to run this code we will use #python3 filename.py

Code Successfully Running

Finally, our Task_7.2_B i.e Setting up Python Interpreter and running python code on docker container is accomplished.

Thank you for reading my article🤗

Keep Learning🤩Keep Sharing🤝🏻

Good Day!

--

--