<p>I am trying to install the azure-cli in the <code>dind:latest</code> image based on alpine.</p>

<p>For context, I want to use it to connect to AKS and deploy an app to Kubernetes via Gitlab.</p>

<p>In my <code>gitlab-ci.yml</code> file I start with this</p>

<pre><code>image: docker:latest
services:
  - docker:dind
</code></pre>

<p>and then I try to install the azure-cli</p>

<pre><code>deploy-to-k8s--dev: # k8s namespace "dev"
  stage: deploy-to-k8s
#  image: microsoft/azure-cli
  script:
    # I need the azure cli in the dind:latest container
    # so install bash,curl and finally the cli
    - apk update
    - apk upgrade
    - apk add bash
    - apk add --no-cache curl

    - curl -L https://aka.ms/InstallAzureCli | bash
    - az
</code></pre>

<p>and I get the following error</p>

<pre><code>$ curl -L https://aka.ms/InstallAzureCli | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   167  100   167    0     0    167      0  0:00:01 --:--:--  0:00:01   644

100  1367  100  1367    0     0   1367      0  0:00:01 --:--:--  0:00:01  1367
mktemp: Invalid argument
ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1
</code></pre>

<p>It is the first time that I try to work with Alpine Linux and I have no idea how it is built and what tools it uses...</p>

<p>Has anyone any suggestion?</p>

<p><strong>EDIT</strong></p>

<p>based on the accepted answer this is the final code that works</p>

<pre><code>deploy-to-k8s--dev: # k8s namespace "dev"
  stage: deploy-to-k8s
  script:
    # I need the azure cli in the dind:latest container
    # so install bash,curl and finally the cli
    - apk update
    - apk upgrade
    - apk add bash make py-pip
    - apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python2-dev
    - pip install azure-cli
    - apk del --purge build
    - az -h
</code></pre>

<p>This helped me in one of my alpine based image</p>

<pre><code>apk update
apk add bash py-pip
apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python- dev
pip install azure-cli
apk del --purge build
</code></pre>
