Skip to content
Related Articles

Related Articles

Improve Article

Docker – Setup in RHEL8 for Python

  • Difficulty Level : Medium
  • Last Updated : 04 Aug, 2021

Developing an application or software requires starting several microservices in one machine. So if you are 10 of those services then you require 10 VMs on that machine. 

How Docker solves the above problem?

With help of docker, you can run multiple microservices in the same VM by running multiple docker containers for each microservices. Containers are like lightweight VMs. Docker is designed to make things easier and efficient by creating, deploying, and running an application inside the containers. You don’t have to pre-allocate any RAM in containers.

As we run our machine learning models in jupyter notebook so to Integrate Machine Learning with DevOps, we can also run our model inside the container. To run your machine learning models and other python projects inside the docker container, here are the few steps that you need to follow to set up the complete environment.

Step 1:Install Docker



  • First, configure docker.repo file inside the directory yum.repo.d.
 cd /etc/yum.repos.d/   

Here cd is used to change the directory and “/etc/yum.repos.d “ is a path and name of the directory.

vim docker.repo   

Here vim is an editor command.

  • Press i to insert, then write all the given below the content
[docker]
baseurl = https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck = 0
name = Docker repo

  • Press esc type :wq , to save.
  • Now to see all the repositories configured under YUM use the below command:
yum repolist     

  • Use the below command for installing docker:
yum install docker-ce --nobest -y  

  • Now start the docker service using the below command:
systemctl start docker 

  • To check the status of docker if it is active or not use the below command:
systemctl status docker 
  • If there is a need to restart docker use the below command:
systemctl restart docker    

Step 2: Launch Container.

  • To pull(downloading the OS image ) the CentOS image from dockerhub use the below command:
docker pull centos:latest  
  • To run the docker container from the pulled image use the below command. Here -it means interactive terminal:
docker run -it centos:latest  

Step 3: Install Python & Libraries inside Container. 

  • Use the below command to install python 3 inside the container to run python code inside it:
yum install python3

  • Now you can install any no. of libraries according to your requirements. For instance to install numpy package use the below command:
pip3 install numpy

At this point, your python setup is ready to work with any python project inside the docker container on RHEL8.

My Personal Notes arrow_drop_up
Recommended Articles
Page :