Python on the top of Docker

🔅 Setting up Python Interpreter and running Python Code on Docker Container …

Now it’s time to integrate technologies and do fun with programming.

CONTAINERIZATION — It is a concept that is a lightweight alternative to the virtual machine. It runs an operating system with a Bootable Image fastly. It is a UserCase used in companies a lot.

Its tools are — Docker Hub, Marathon, Swarm, Kubernetes, etc.

DOCKER — Docker is a tool that uses O.S. level virtualization to deliver software into packages called containers. Docker uses Bootable images to run the operating system in just 1 second. Docker is a powerful tool made by Solomon Hykes.

Today I am going to run Python Interpreter on top of Docker by using bootable images which will be internally downloaded from DOCKER HUB.

IMAGE

The image i am showing is from Docker Hub and this is the place from where docker will pull the image.I am using Centos image in this task.

Docker Hub

______________________________

PULL THE IMAGE

“ docker pull centos ” is the command used to download the image on the BaseOS.

pull the image

______________________________

DOCKER IMAGES ON BASEOS

To see which images are present on our RedHat system we use the “docker images ” command. Here Centos image is downloaded.

check docker images

______________________________

LAUNCH+BOOT+LOGIN INTO CONTAINER

docker run -it — name PythonInterpreter centos is the drastic command which launch + boot + login into the Operating System in just 1 second. Here you can see that the terminal changed from BaseOS to Docker Container.

Launch + Boot + Login

______________________________

SELINUX

“ setenforce 0 ” is a command which changes SElinux from targeted to Permissive Mode. In this mode, we can perform all actions and it will not give any security issue.

SELinux mode changed

______________________________

PYTHON NOT FOUND

See python is not present in the container.

check python is running or not??

______________________________

INSTALL PYTHON

yum install python3 is the command to install python on a docker container.

install python

______________________________

PYTHON INTERPRETER

“ python3 ” is the command which helps the user to enter into a python interpreter.

python interpreter

______________________________

MAKE A PYTHON FILE

I am making a python file with [.py] extension and writing a code in it so that we will run it on a docker container.

create a file by vi editor
code

______________________________

RUN PYTHON PROGRAM FILE

python3 file.pyis the command used to run a python program file.

run code

______________________________

EXIT

“ exit ” is a command through which docker container shut and come back to BaseOS terminal.

exit

______________________________

THANK YOU FOR READING MY ARTICLE!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store