'az cli missing on docker image on mac after doing curl call
I have the following in my Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:6.0
RUN apt update
RUN apt-get install vim -y
COPY . /builds
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
RUN apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install nodejs
RUN npm install -g azure-functions-core-tools@4 --unsafe-perm true
At this point if I create a container using this new image, on my windows host I can do this:
root@5a75ab66011b:/builds# az --version
azure-cli 2.35.0
core 2.35.0
telemetry 1.0.6
Dependencies:
msal 1.17.0
azure-mgmt-resource 20.0.0
Python location '/opt/az/bin/python3'
Extensions directory '/root/.azure/cliextensions'
Python (Linux) 3.8.12 (default, Apr 1 2022, 06:20:19)
[GCC 10.2.1 20210110]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
root@5a75ab66011b:/builds#
On my m1 macbook pro:
root@4fb97a21813a:/builds# az
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
root@4fb97a21813a:/builds#
So I tried to manually redo the curl command like this:
root@4fb97a21813a:/builds# curl -sL https://aka.ms/InstallAzureCLIDeb | bash
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Hit:4 https://packages.microsoft.com/repos/azure-cli bullseye InRelease
Hit:5 https://deb.nodesource.com/node_12.x bullseye InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apt-transport-https is already the newest version (2.2.4).
curl is already the newest version (7.74.0-1.3+deb11u1).
gnupg is already the newest version (2.2.27-2+deb11u1).
lsb-release is already the newest version (11.1.0).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Hit:4 https://packages.microsoft.com/repos/azure-cli bullseye InRelease
Hit:5 https://deb.nodesource.com/node_12.x bullseye InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
azure-cli is already the newest version (2.35.0-1~bullseye).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
root@4fb97a21813a:/builds# az
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
root@4fb97a21813a:/builds#
It seems to be indicating that I have installed azure-cli ... but it won't run. Any tips would be appreciated.
Edit 1
I've tried building the image like this:
docker build -t azuredeployment . --platform linux/amd64
instead of:
docker build -t azuredeployment .
but no dice. I get the same results.
I also tried to change the way I run the docker container but I can't seem to get the command going :
docker run -d azuredeployment --platform linux/x86_64
gives me the error
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "--platform": executable file not found in $PATH: unknown.
EDIT 2
Got it mostly working.
I changed the docker file from this:
FROM mcr.microsoft.com/dotnet/sdk:6.0 \
to this:
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0
and it works. Albeit, I have this little icon with an exclamation mark next to it in docker desktop saying the image may not run properly.
I also tried to use the arm64 version like this:
FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/sdk:6.0
I don't have the warning icon next to my running container but ... i still get the same error message.
EDIT 3
So in this end, this is the syntax I'm working with in the FROM :
FROM mcr.microsoft.com/dotnet/sdk:6.0.202-bullseye-slim-amd64
RUN apt update && apt-get install vim -y
COPY . /builds
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
RUN apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install nodejs
RUN npm install -g azure-functions-core-tools@4 --unsafe-perm true
It seems the az cli installs properly. But here's a screenshot showing the status of the running container. You can also see the warning icon I was trying to describe.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

