Linux

Utilizing Singularity Containers for Python Environments

2020/10/26

This article explains that the utilization of Container technology on Linux generates particular Python environments, driving the Selenium automation browser.

Generally speaking, we do not want to modify and destroy our Linux PC environments because of some programming tests and their fancy environments. But, utilizing Containers will allow readers to build compact, lightweight, and reproducible virtual operating systems without destroying environments of PC.

Utilizing Singularity Containers for Python Environments

What is Container?

This answer is straight-forward. It's the open-source lightweight virtual operating systems using the host Linux kernel. The performance after containerization is, in general, much better than full virtualized machines such as VMWare, VirtualBox, and so on.

Let's imagine if you have a program developed by you on your PC, which has been driven by a particular Linux distribution such as Ubuntu 18. You confirmed it worked on your PC. But, what happens if you install it into the other PC using older Ubuntu distributions?

The simplest way is building the other Linux and distribution environments with particular programming libraries you've used, and let's run your program.

We can use the Containers as lightweight production environments, without considering complicated configurations in the Linux OS.

So, your program will work as if it's in a CONTAINER without knowing the complex inside content.

Docker

Docker is the most popular for providing container platform, image distributor (DockerHub), and execution environments developed by the Docker company. We can quickly write the virtual operating system configuration in the Docker configuration called Dockerfile.

For example, we can define CentOS7 and installing the Firefox browser. We write a Dockerfile.

Once we execute a docker command, we can build an image of the virtual operating system.

Then run the container.

Docker command is a client for interacting with the Docker daemon through the CLI.

Singularity

Singularity is an open source-based container platform designed for scientific and High-Performance Computing environments with the following features.

  1. Containers can be started and stopped with a general user account. You do not need to grant sudo privileges to your user account.
  2. Docker images are available.
  3. The owner of the user account in the container is inherited from the host PC. Even if you create and edit a file in a container, the owner remains.
  4. Supports GPU virtualization
  5. Bind (share) under $ HOME on the host to the container

  • By default, the container instance can share the home directory. So, it is easy to move and copy data from and to your home director.
  • If the system administrator allows the user to bind, the user can also specify the bind source and destination.

Instlling Singularity

In Ubuntu Linux

In CentOS Linux

Basic commands of Singualrity

Let's build the latest CentOS operating system on a Singularity container. We build the singularity image file as centos7.sif.

Now, we can access the container by shell.

Building Python environment and installing libraries

Conclusion

-Linux

Copyright© Mariendorf Group , 2024 All Rights Reserved.