Python (AlmaLinux 8)

Python (AlmaLinux 8)

  • OS: almalinux 8

Description

Python is a high-level, interpreted, object-oriented programming language, widely used for developing various types of software applications. Python is known for its easy-to-learn syntax and diverse functionalities that can be used for creating web applications, games, scientific research, machine learning, artificial intelligence, and much more. Python is a platform-independent language that can be used on different operating systems, including Windows, Linux, and macOS. Additionally, Python offers a rich library of modules and tools that make software development faster and more efficient.

Software included

Package Version
Python 3.11
Docker 3.20.10
Docker compose 2.12.2
containerd.io 1.6.10

Initial start of the service

This application uses Docker to provide faster startup of the underlying software (Python) and direct use. This eliminates the need to familiarize yourself with its specifics in terms of configuration and installation. To start working directly with the application, all you have to do is upload the content that you want Python to serve to the /opt/python/data/ directory.

Quick settings and frequently asked questions

  • Logging into the cloud service is done using an SSH key or password that you have specified.
  • Docker is installed as recommended by the official docker documentation.
  • The standard docker and docker compose commands are now available in this application.
  • When the virtual machine is first started, it takes a few minutes before a Docker container containing Python is started.
  • The Python data where you should deploy your application is located in /opt/python/data/.
  • The port the service is running on is 8000.

Note: Port 8000 is configured as example only. To use this docker image network functionality, your application also need to support this.

Additional Docker settings

You can configure extra settings as variables for this docker application from it's configuration file /opt/docker-python/docker-compose.yml.

Note: After changing any of parameters in your configuration file docker-compose.yml you will need to recreate the container. For more information, please see Recreating Docker containers section.

Additional helpful tips

  • If you want to use the Python CLI, you can do it with the quick command docker exec -ti docker-python-python-1 python <COMMAND>.
  • If you often use the Python CLI, you can also make a quick shortcut by adding an alias as follows:
echo "alias python='docker exec -ti docker-python-python-1 python'" >> ~/.bashrc
source ~/.bashrc

Working with Docker

The organization of this application is entirely done using Docker. In this way, we can provide you with ready-made applications faster. In addition, their configuration is more flexible and quite controllable. To be able to control this application, however, you need to know some basic Docker functionalities and features.

Restarting all services

Restarting the database and the Docker container that contains Python itself, along with the rest of the software, can be done in two ways:

  1. By restarting the entire virtual machine
  2. Restarting the Docker containers, which is the faster option. To do this, access your machine via SSH, and run the following commands:
sudo su -
cd /opt/docker-python/
docker compose restart

Checking the status of the Docker application

To check, you need to run the following commands:

sudo su -
docker ps -a

Please pay attention to the STATUS column. It should show how long the service has been running, for example Up X minutes. If the status is Restarting then you need to check what is wrong with the application. In such a case, you can check by following the application logs as follows:

  1. Get the application name that you can see in the NAMES column from the output of the docker ps -a command. View the logs with the docker logs <NAME> command, where is the name of the container.

Changing settings

The settings in section Additional Docker settings can be set in the docker-compose.yml file. The path to it is described again in this section. To change a setting, open the configuration file and note the environment section under python. Each configuration option must be described on a new line with a dash in front, as in the following example:

    environment:
      - APACHE_HTTP_PORT_NUMBER=8080

Please note that the correct indentation (number of spaces) must also be observed, as this is important for yaml configuration files.