Installing Python in Docker Container in RHEL8(Red Hat Enterprise Linux)
Dear Readers,
I would first suggest you to install Docker in RHEL-8. If you haven’t, you can refer to my blog on how to Install Docker in RHEL-8:
1. Open RHEL-8 terminal.
2. Now, launch a container using command:
(i) To launch a container with a name you want-
docker run -it –name <container_name> centos:latest
(ii) To launch a container with a random name-
docker run -it centos:latest
3. If you want to work on a previously created container that is running or has been stopped, use the command: docker ps
to check for running container or docker ps -a
to check for exit status containers and then start them using command : docker start <container_name/container_id>
and then get inside the container terminal using command : docker attach <container_name/container_id>
.
In the image below you can see I was inside the container terminal and despite exiting the container, I opened the RHEL8 terminal using:Left Control Key+p+q.
I did this to check if current container was running or no. You can do this to perform other tasks too.
4. Install PYTHON using yum install python3-pip
5. Your Python is installed in the container and now, if you want to download packages such as numpy, pandas, etc. you need to install them using:
pip3 install <package_name/library_name>
in the container terminal.
6. To start using Python, inside your container, type: python3
and to exit from the python workspace, type: exit()
.
And now we have installed Python inside our docker container; and have also seen how we can enter,exit a Python workspace and how we can download packages.