1

Тема: Docker на Linux Ubuntu

Завдання: запустити Flask-додаток.
Встановив Flask3, python, створив файл Dockerfile:

FROM ubuntu:latest
MAINTAINER Yaroslav Shcherbyna PP-23 "yaroslav.shcherbyna.pp.2022@lpnu.ua"
ENV container_number 1
RUN mkdir app
COPY . /app
WORKDIR /app
RUN apt-get update -y
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
EXPOSE 5000
CMD python3 hello.py -C $container_number

Файл конфігурації (requirements.txt):

requests
Flask==0.12

Під час введення команди

$ sudo docker build -t diploma:latest .

вибиває помилку на кроці

RUN pip3 install --upgrade pip

:

=> ERROR [6/7] RUN pip3 install --upgrade pip    0.3s
------
> [6/7] RUN pip3 install --upgrade pip:
0.265 /bin/sh: 1: pip3: not found
------
Dockerfile:8
--------------------
   6 |     WORKDIR /app
   7 |     RUN apt-get update -y
   8 | >>> RUN pip3 install --upgrade pip
   9 |     RUN pip3 install -r requirements.txt
  10 |     EXPOSE 5000
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install --upgrade pip" did not complete successfully: exit code: 127

2

Re: Docker на Linux Ubuntu

RUN apt-get install -y python3-pip

3

Re: Docker на Linux Ubuntu

=> ERROR [7/8] RUN pip3 install --upgrade pip    0.5s
------
 > [7/8] RUN pip3 install --upgrade pip:
0.427 error: externally-managed-environment
0.427
0.427 × This environment is externally managed
0.427 ╰─> To install Python packages system-wide, try apt install
0.427     python3-xyz, where xyz is the package you are trying to
0.427     install.
0.427     
0.427     If you wish to install a non-Debian-packaged Python package,
0.427     create a virtual environment using python3 -m venv path/to/venv.
0.427     Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
0.427     sure you have python3-full installed.
0.427     
0.427     If you wish to install a non-Debian packaged Python application,
0.427     it may be easiest to use pipx install xyz, which will manage a
0.427     virtual environment for you. Make sure you have pipx installed.
0.427     
0.427     See /usr/share/doc/python3.12/README.venv for more information.
0.427 
0.427 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.
0.427 hint: See PEP 668 for the detailed specification.
------
Dockerfile:9
--------------------
   7 |     RUN apt-get update -y
   8 |     RUN apt-get install -y python3-pip
   9 | >>> RUN pip3 install --upgrade pip
  10 |     RUN pip3 install -r requirements.txt
  11 |     EXPOSE 5000
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install --upgrade pip" did not complete successfully: exit code: 1

4

Re: Docker на Linux Ubuntu

В мене таке на alpine linux видає, мені не зрозуміло чому воно у вас на Убунту вилазить.

error: externally-managed-environment