Have you ever spent hours trying to understand why your Docker container can't find Python? At Q2BSTUDIO, a company specialized in development and technology services, we've experienced it. When building Docker images for Python applications, it's common to encounter the error that the python command is not available, despite having correctly installed python3. This small but significant problem can cause complete container failures, break CI/CD pipelines, and waste valuable development time.
The issue lies in the fact that many modern Linux distributions, including those used in containers like Ubuntu 22.04, install Python 3 under the name python3, while numerous scripts still simply invoke python. This mismatch between the actual executable name and the one used by developers or automated tools is the perfect recipe for a frustrating error.
At Q2BSTUDIO, we recommend a simple yet effective solution that we apply in all our Docker environments: creating symbolic links. Simply add the following lines to your Dockerfile:
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip
These commands create shortcuts called python and pip that point to their respective Python 3 versions. This way, any command or script using the classic versions will work seamlessly, maintaining maximum compatibility without compromising the use of Python 3.
Some might suggest using shell aliases, such as adding alias python=python3 to bashrc. However, at Q2BSTUDIO we have found that this does not work reliably, especially in non-interactive contexts like automated scripts or build processes. Symbolic links work in all cases, offering a robust and definitive solution.
This small adjustment has transformed the way we create Docker images. It is a clear example of how a simple change can prevent many headaches in software development. At Q2BSTUDIO, we apply this type of good practice daily to ensure efficient and reliable execution environments for our clients.
Do you have any small Docker trick that has made your life easier? At Q2BSTUDIO, we are always open to improving our processes, because we know that the difference lies in the details.





