简体   繁体   中英

How to install azure-cli on python docker image

I am trying to install azure-cli in a python docker container but I get the following error:

[5/5] RUN pip3 install azure-cli:
#9 1.754 Collecting azure-cli
#9 1.956 Downloading azure_cli-2.43.0-py3-none-any.whl (4.3 MB)
#9 7.885 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 730.7 kB/s eta 0:00:00
#9 8.070 Collecting six>=1.10.0
#9 8.190 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) #9 8.227 Collecting azure-loganalytics~=0.1.0. . . #9 43.08 ERROR: Exception: . . . #9 43.08 raise IncompleteRead(self._fp_bytes_read, self.length_remaining) #9 43.08 File "/usr/local/lib/python3.7/contextlib.py", line 130, in exit #9 43.08 self.gen.throw(type, value, traceback) #9 43.08 File "/usr/local/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 449, in _error_catcher #9 43.08 raise SSLError(e) #9 43.08 pip._vendor.urllib3.exceptions.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:2570) #9 43.28 WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available. #9 43.28 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.


executor failed running [/bin/sh -c pip3 install azure-cli]: exit code: 2

And here's my Dockerfile

FROM python:3.7-alpine

RUN apk add --update git bash curl unzip make coreutils openssh shadow

ARG TERRAFORM_VERSION="1.3.6"
ARG svgUserId=
ENV AZURE_DEFAULT_REGION=germanywestcentral

RUN if ! id $svgUserId; then \
    adduser svg -D &&\
    usermod -u ${svgUserId} svg; \
  fi

RUN curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip > terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
  unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /bin && \
  rm -f terraform_${TERRAFORM_VERSION}_linux_amd64.zip

RUN pip3 install azure-cli

ENTRYPOINT []

Can someone help me find the issue?

Use below commands to install azure-cli in alpine image:

RUN apk add --no-cache --update python3 py3-pip 
RUN apk add --no-cache --update --virtual=build gcc musl-dev python3-dev libffi-dev openssl-dev cargo make && pip3 install --no-cache-dir --prefer-binary azure-cli && apk del virtual

As you use Python alpine image, the first RUN command is redundant in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM