Cannot Build Docker on Ubuntu 22.04
Closed this issue · 1 comments
rahadiancs commented
Please help, I tried to build the docker image on Ubuntu 22.04 VM, but getting this error:
=> ERROR [2/9] RUN apk add --no-cache python3 && python3 -m ensurepip && pip3 install --upgrade pip setu 5.8s
------
> [2/9] RUN apk add --no-cache python3 && python3 -m ensurepip && pip3 install --upgrade pip setuptools && if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi:
0.298 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
0.860 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
1.500 (1/17) Installing libexpat (2.6.2-r0)
1.527 (2/17) Installing libbz2 (1.0.8-r6)
1.549 (3/17) Installing libffi (3.4.4-r3)
1.570 (4/17) Installing gdbm (1.23-r1)
1.595 (5/17) Installing xz-libs (5.4.5-r0)
1.630 (6/17) Installing libgcc (13.2.1_git20231014-r0)
1.657 (7/17) Installing libstdc++ (13.2.1_git20231014-r0)
1.760 (8/17) Installing mpdecimal (2.5.1-r2)
1.790 (9/17) Installing ncurses-terminfo-base (6.4_p20231125-r0)
1.821 (10/17) Installing libncursesw (6.4_p20231125-r0)
1.858 (11/17) Installing libpanelw (6.4_p20231125-r0)
1.878 (12/17) Installing readline (8.2.1-r2)
1.917 (13/17) Installing sqlite-libs (3.44.2-r0)
2.003 (14/17) Installing python3 (3.11.9-r0)
2.875 (15/17) Installing python3-pycache-pyc0 (3.11.9-r0)
3.339 (16/17) Installing pyc (3.11.9-r0)
3.357 (17/17) Installing python3-pyc (3.11.9-r0)
3.377 Executing busybox-1.36.1-r15.trigger
3.395 OK: 51 MiB in 32 packages
5.614 error: externally-managed-environment
5.614
5.614 × This environment is externally managed
5.614 ╰─>
5.614 The system-wide python installation should be maintained using the system
5.614 package manager (apk) only.
5.614
5.614 If the package in question is not packaged already (and hence installable via
5.614 "apk add py3-somepackage"), please consider installing it inside a virtual
5.614 environment, e.g.:
5.614
5.614 python3 -m venv /path/to/venv
5.614 . /path/to/venv/bin/activate
5.614 pip install mypackage
5.614
5.614 To exit the virtual environment, run:
5.614
5.614 deactivate
5.614
5.614 The virtual environment is not deleted, and can be re-entered by re-sourcing
5.614 the activate file.
5.614
5.614 To automatically manage virtual environments, consider using pipx (from the
5.614 pipx package).
5.614
5.614 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.
5.614 hint: See PEP 668 for the detailed specification.
5.674 Traceback (most recent call last):
5.674 File "<frozen runpy>", line 198, in _run_module_as_main
5.674 File "<frozen runpy>", line 88, in _run_code
5.674 File "/usr/lib/python3.11/ensurepip/__main__.py", line 5, in <module>
5.675 sys.exit(ensurepip._main())
5.676 ^^^^^^^^^^^^^^^^^
5.677 File "/usr/lib/python3.11/ensurepip/__init__.py", line 286, in _main
5.677 return _bootstrap(
5.677 ^^^^^^^^^^^
5.677 File "/usr/lib/python3.11/ensurepip/__init__.py", line 202, in _bootstrap
5.678 return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
5.678 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.678 File "/usr/lib/python3.11/ensurepip/__init__.py", line 103, in _run_pip
5.679 return subprocess.run(cmd, check=True).returncode
5.679 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.680 File "/usr/lib/python3.11/subprocess.py", line 571, in run
5.681 raise CalledProcessError(retcode, process.args,
5.681 subprocess.CalledProcessError: Command '['/usr/bin/python3', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpnp3av3re/setuptools-65.5.0-py3-none-any.whl\', \'/tmp/tmpnp3av3re/pip-24.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpnp3av3re\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
------
Dockerfile:2
--------------------
1 | FROM alpine:latest
2 | >>> RUN apk add --no-cache python3 && \
3 | >>> python3 -m ensurepip && \
4 | >>> pip3 install --upgrade pip setuptools && \
5 | >>> if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
6 | >>> if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi
7 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apk add --no-cache python3 && python3 -m ensurepip && pip3 install --upgrade pip setuptools && if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi" did not complete successfully: exit code: 1
rahadiancs commented
Changed the image to Alpine 3.15 on Dockerfile, problem solved.
The latest Alpine image uses Python 3.11 which enforce the use of venv (or so I read)