Hello
I am new on Docker
My host linux is Ubuntu 22.4
I am trying to build a container within which I will be able to run python with a java module.
My Dockerfile is as follows:
FROM ubuntu:latest
WORKDIR /app
RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install java
COPY error_check.py .
COPY run_test.sh .
COPY java-test-cases /app/java-test-cases
CMD ["bash", "run_test.sh"]
When trying to build the image, I get the below errors:
ERROR [4/7] RUN pip3 install java
[4/7] RUN pip3 install java:
4.022 error: externally-managed-environment
4.022
4.022 × This environment is externally managed
4.022 ╰─> To install Python packages system-wide, try apt install
4.022 python3-xyz, where xyz is the package you are trying to
4.022 install.
4.022
4.022 If you wish to install a non-Debian-packaged Python package,
4.022 create a virtual environment using python3 -m venv path/to/venv.
4.022 Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
4.022 sure you have python3-full installed.
4.022
4.022 If you wish to install a non-Debian packaged Python application,
4.022 it may be easiest to use pipx install xyz, which will manage a
4.022 virtual environment for you. Make sure you have pipx installed.
4.022
4.022 See /usr/share/doc/python3.12/README.venv for more information.
4.022
4.022 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
4.022 hint: See PEP 668 for the detailed specification.
Dockerfile:6
4 |
5 | RUN apt-get update && apt-get install -y python3-pip
6 | >>> RUN pip3 install java
7 | COPY error_check.py .
8 | COPY run_test.sh .
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install java" did not complete successfully: exit code: 1
How can i resolve the errors?