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.
______________________________
PULL THE IMAGE
“ docker pull centos ” is the command used to download the image on the BaseOS.
______________________________
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.
______________________________
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.
______________________________
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.
______________________________
PYTHON NOT FOUND
See python is not present in the container.
______________________________
INSTALL PYTHON
“ yum install python3 ” is the command to install python on a docker container.
______________________________
PYTHON INTERPRETER
“ python3 ” is the command which helps the user to enter into a 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.
______________________________
RUN PYTHON PROGRAM FILE
“ python3 file.py” is the command used to run a python program file.
______________________________
EXIT
“ exit ” is a command through which docker container shut and come back to BaseOS terminal.
______________________________
THANK YOU FOR READING MY ARTICLE!!