Docker run armv7 images on mac - macos

My mac uses x86_64 hardware and in theory I shouldn't be able to run docker images built for armv7.
HOWEVER
Docker documentation says:
Docker Desktop provides binfmt_misc multi-architecture support, which means you can run containers for different Linux architectures such as arm, mips, ppc64le, and even s390x.
This does not require any special configuration in the container itself as it uses qemu-static from the Docker for Mac VM.
and I'm also reading articles like this one which confirm the above
docker run -it --rm arm32v7/debian /bin/bash
should work on a mac although it doesn't work for me:
Unable to find image 'arm32v7/debian:latest' locally
latest: Pulling from arm32v7/debian
Digest: sha256:9b61eaedd46400386ecad01e2633e4b62d2ddbab8a95e460f4e0057c612ad085
Status: Image is up to date for arm32v7/debian:latest
docker: Error response from daemon: image with reference arm32v7/debian was found but does not match the specified platform cpu architecture: wanted: amd64, actual: arm.
See 'docker run --help'.
I wonder whether I'm misunderstanding something.
Docker desktop community version 2.4.2.0 (48975) edge
Docker version 20.10.0-beta1, build ac365d7
MacOS version 10.15.7 (19H2)
Note: while researching the topic I've tryied to use qemu and ran:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
which has potentially interfered with the default behaviour.

I think my problem is related to this moby issue.
The fix was quite trivial as I only needed to add the --platform argument, in my case linux/arm or linux/arm/v7:
docker run -it --rm arm32v7/debian /bin/bash
has become
docker run --platform=linux/arm -it --rm arm32v7/debian /bin/bash
and voila:
root#82c3ff8752d3:/# uname -a
Linux 82c3ff8752d3 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020 armv7l GNU/Linux

Related

Docker run -d changes container architecture

I was trying to install software on 32-bit CentOS 4.8 and ran into a problem. I ran the container using docker run -d(or -itd). The installation software keeps pointing to a x86_64 folder where it doesn't exist. I was so confused because I'm sure I used the correct CentOS image. I ran uname -a and it tells me that my container architecture is 64-bit (x86_64).
I try to run it using docker run -it command instead and when I check uname -a it correctly shows that I'm using 32-bit image.
My question is, is there any explanation why -d flag changes the architecture?
I'm using Docker version 20.10.5 on Windows 10 (64-bit).
Edit: Even when I start a stopped container from docker run -it command using docker start, it use 64-bit architecture instead. I need to run it using docker start -i.

how to run amd64 docker images on arm64 host platform

I have an m1 mac and I am trying to run a amd64 based docker image on my arm64 based host platform. However, when I try to do so (with docker run) I get the following error:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested.
When I try adding the tag --platform linux/amd64 the error message doesn't appear, but I can't seem to go into the relevant shell and docker ps -a shows that the container is immediately exited upon starting. Would anyone know how I can run this exact image on my machine given the circumstances/how to make the --platform tag work?
Using --platform is correct. On my M1 Mac I'm able to run both arm64 and amd64 versions of the Ubuntu image from Docker Hub. The machine hardware name provided by uname proves it.
# docker run --rm -ti --platform linux/arm/v7 ubuntu:latest uname -m
armv7l
# docker run --rm -ti --platform linux/amd64 ubuntu:latest uname -m
x86_64
Running amd64 images is enabled by Rosetta2 emulation, as indicated here.
Not all images are available for ARM64 architecture. You can add --platform linux/amd64 to run an Intel image under emulation.
If the container is exiting immediately, that's a problem with the specific container you're using.
To address the problem of your container immediately exiting after starting, try using the entrypoint flag to overwrite the container's entry point. It would look something like this:
docker run -it --entrypoint=/bin/bash image_name
Credit goes to this other SO answer that helped me solve a similar issue on my own container.

How to run Dockerfile at Silicon Mac M1 from Intel Mac

I'm not a native speaker of English, but I want to ask a question on Stack Overflow.
and I am a beginner at Docker.
I am trying to set up the development environment at Silicon Mac M1 from Intel mac.
#!/bin/sh
set -e
. ./env.list
# Build Docker image
# docker pull store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
docker build -t ${REPOSITORY}:${TAG} .
# DOCKERFILE
FROM store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
RUN yum -y update && yum clean all
RUN curl ftp://ftp.pbone.net/mirror/vault.centos.org/7.8.2003/os/x86_64/Packages/glibc-common-2.17-307.el7.1.x86_64.rpm > /tmp/glibc-common.rpm
RUN rm -f /etc/localtime
RUN mkdir /var/custom
and I got errors like below
Step 2/30 : RUN yum -y update && yum clean all
---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
I already add --platform linux/amd64 another docker run command
#!/bin/bash
. ./env.list
docker rm -f api-db
docker run --name api-db -h db2server --restart=always --detach --privileged=true -p 50000:50000 -p 55000:55000 --platform linux/amd64 --env-file env.list sample-app:v1.0
what should I do for a dockerfile?
Thank you so much for reading.
Have a good day! :)
Apple M1 is arm64v8 instruction set processor, so you can not run amd64 (X86_64) on it without emulation. In general, Docker has the ability to emulate other architectures if the emulation based on bitfmt is set up (and on maxOS with intel CPU it's already set-up), however the emulation for amd64 on M1 is not stable yet. This means that for some period of time you will be restricted to 'arm64' images.
To fetch the proper image for you architecture during the build you need to add the following.
FROM --platform linux/arm64 <image name>
You need to check if there are images for db2 development environment for arm by doing
docker pull --platform linux/arm64 store/ibmcorp/db2_developer_c

Is it possible to install CNTK on a macbook?

It is possible to install Microsoft CNTK on a macbook? I have OS X El Capitan. The official Microsoft documentation at https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-your-machine doesn't provide any information for mac users.
Thank you
As of June 2017, you can only run CNTK on OSX using Docker (which will run a Linux container)
Documentation from Microsoft is available here: https://learn.microsoft.com/en-us/cognitive-toolkit/CNTK-Docker-Containers
If you want to run the CPU version of CNTK (as opposed to a GPU enabled) you'll need to pull a particular version of the docker container. See: https://hub.docker.com/r/microsoft/cntk/
I recommend using the following for CPU CNTK:
docker pull microsoft/cntk:2.0-cpu-python3.5
Once you've pulled the container above, you can use Jupyter Notebooks to look at tutorials etc:
First, run the container:
docker run -d -p 8888:8888 --name cntk-jupyter-notebooks -t microsoft/cntk:2.0-cpu-python3.5
Then run this command:
docker exec -it cntk-jupyter-notebooks bash -c "source /cntk/activate-cntk && jupyter-notebook --no-browser --port=8888 --ip=0.0.0.0 --notebook-dir=/cntk/Tutorials --allow-root"
You'll want to access the shell to run CNTK commands. You can attach a bash shell using docker.
Get your container id
docker ps
Then attach a shell
docker exec -it <container_id> bash
While it might not be supported on Mac directly, you can always use a virtual machine to get around.
You can setup docker in your local environment.
https://docs.docker.com/docker-for-mac/
Follow its documentations on how to install on Docker
https://github.com/Microsoft/CNTK/wiki/CNTK-Docker-Containers
We currently support both Linux and Windows. Mac support is on our ToDo or would be interested in community contribution.
I'm currently building CNTK on a linux machine without root access, installing every dependency with linuxbrew (a fork of homebrew). So I think is possible to build on MacOS natively. You can try building it from source with CNTK linux manual to build from source. Let me know if you have any issue.

Run a docker image on Windows results in "oci runtime error: exec: "bash": executable file not found in $PATH."

I'm running Docker on Windows ("Docker Toolbox", not "Docker for Windows").
I've built an image with a rails app inside. It works properly on my Mac OS but stucks on production on Windows.
Using Docker 1.12 and docker-machine 0.8.0 on both machines.
When I create a machine and try to run the container from image, I do:
docker run -it myRepo:myTag bash
which opens me a interactive terminal on Mac OS, but Windows 7 and Windows Server 2011 are both responding with:
"Error response from daemon: oci runtime error: exec: "bash":
executable file not found in $PATH."
I use the MINGW64 shell via the Docker Quickstart Terminal but the old cmd.exe returns the same.
Can anybody help me with this issue? I've tried several hours to find a solution but there are too few answers for Windows.
Thank you in advance!
I also use Windows 7 with MINGW64. Here is what I get using nginx as example:
$docker run -it nginx bash
cannot enable tty mode on non tty input
I don't think you can open a tty using MINGW64.
You can try:
$docker run -i nginx bash
ls
bin
...
You will so no prompt or any indication you are inside the container. Just run ls and it should work inside your container.
Another option is to try to use winpty for the tty:
$ winpty docker run -it myRepo:myTag bash
root#644f59e6f818:/#
Have you tried?
$ winpty docker run -it myRepo:myTag /bin/bash
I haven't got the problem you are mentioning but I have seen it before when I was mapping volumes.
If you are mapping volumes using MINGW64, you will need to add an extra / before the local mapping. For example:
docker run -p 8080:80 -v "/$PWD":/var/share/nginx/html nginx
Let me know your findings.

Resources