Build Docker image for ARM architecture on Intel machine (Mac)

后端 未结 1 883
野的像风
野的像风 2021-01-03 10:19

I\'d like to be able to build a Docker image for ARM from my Mac. I know I can run ARM containers on my Mac using QEMU but I can\'t figure out how to build for ARM.

相关标签:
1条回答
  • 2021-01-03 10:41

    This is a little convoluted right now. I am sure it will be made easier by docker in the near future.

    Basically you need to build a contained based on a container that has the qemu-arm-static binary in it already.

    You can see how it is done by looking at Raspberry Pi base image w/qemu-arm-static which builds the images directly with travis.

    What I did was basically on my raspberry pi build my base docker image with this binary added and push that to the docker-hub.

    Once I have that image as my base I can build and run containers that are derived from it, including building new derived containers, on my OSX machines and then run it on my raspberry pi's unmodified.

    On my raspberry pi I build an image using this Dockerfile. I am starting with hypriot's base alpine image. You should be able to use any base image you want.

    FROM hypriot/rpi-alpine-scratch
    
    RUN apk update && \
    apk upgrade && \
    apk add bash && \
    rm -rf /var/cache/apk/*
    
    COPY qemu-arm-static /usr/bin/qemu-arm-static
    
    CMD ["/bin/bash"]
    

    Once I push that to Dockerhub I know have a container I can build based on on my intel machines and run and build on my raspberry pi's.

    The qemu-arm-static binary I got by launching a debian i386 docker container, installing qemu-user-static and copying the binary out.

    0 讨论(0)
提交回复
热议问题