Pull the Docker container image of CentOS image from DockerHub and create a new container:

Step 1:

Launching the redhat OS 

Step 2: Checking the status of docker using the command

systemctl status docker

Make sure that docker is installed.

Step-3:

Pulling centos ( latest version ) on docker container. Command for it is

docker pull centos:8

Step-4:

Launching an OS on docker 

docker run -it centos:8 
# This command means launching an OS ( centos ) on docker ( as a container ). This OS gets a garbage name. To assign a name , following command can be used
docker run -it --name myos centos:8 
#Here the name of the OS , launched is myos 

The OS is successfully launched. To confirm it , the tag is changed from [ root@localhost ~ ] to [ root@ idno ~ ]

Apart from this , we also can check the containers by using the following command in new window terminal.

docker ps

Here in this image, there were two containers launched. Here the two containers were launched successfully on docker containers on top of centOS image. 

Installing python on docker container:

To install python on docker container, the following command is used ( making sure that linux OS has active internet connection )

Press y 

Press y again

Python is successfully installed on docker container. 

Creating ML model on docker:

For this we need to install few libraries on container. Pandas is the important most library , to install it , command line is

pip3 install pandas

Next library is scikit-learn, command for this is

pip3 install scikit-learn

Now Let’s create a python file , command line is

vi mldcker.py

And press i to write code 

Once the code is completed return back

Now run the python file using the command 

python3 mldckr.py

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *