Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image doesn't work on Mac with M1 chip #1

Closed
nicole-brewer opened this issue Mar 15, 2024 · 1 comment
Closed

Docker image doesn't work on Mac with M1 chip #1

nicole-brewer opened this issue Mar 15, 2024 · 1 comment

Comments

@nicole-brewer
Copy link
Contributor

nicole-brewer commented Mar 15, 2024

My goal

I'd like to be able to use the repo2docker-action to create a Docker image based of the configuration files in my repository.

What is working

I am able to successfully create such an image under name brewer36/jupyter-mentor:latest with the following GitHub actions configuration:

name: Build Notebook Container
on: [push, workflow_dispatch]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:

    - name: checkout files in repo
      uses: actions/checkout@main

    - name: update jupyter dependencies with repo2docker
      uses: jupyterhub/repo2docker-action@master
      with:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

The problem

My problem is that I'm finding it difficult to get GitHub actions to create a Docker image that is compatible with the Mac M1 chip, which has arm64 architecture. All of my attempts thus far, no matter what configuration variables I use, result in an amd64 image. Docker warns me that that this image may have poor performance or fail, because the image is based off of a different architecture.

Screenshot 2024-03-15 at 12 30 04 PM

What I have been able to get working

As debugging a remote action is time consuming and difficult, I started first trying to make progress locally. I installed repo2docker and looked at various issues discussing how to make repo2docker work with a Mac M1. Issue #1174 was helpful because it showed me how to specify extra build args that are not in the repo2docker documentation on the web (it is only available by running repo2docker --help-all). Specifically the argument --Repo2Docker.extra_build_args=platform=linux/amd64. Using this flag, I am able to build a similar Docker image on my local machine using the command

repo2docker --Repo2Docker.platform=linux/arm64 --image-name=brewer36/jupyter-mentor:macos ./

where ./ refers to the current directory, which is the base directory of my local clone of the Jupyter4Science/jupyter-mentor) repository. This results in a local Docker image I can then push to my DockerHub account.

Screenshot 2024-03-15 at 1 24 43 PM

This solution may have to be "good enough".

What has not worked for me

Ideally, I'd like to get this working from github actions so I don't have to do it locally, but as of today I'm not sure this is possible. I tried using the platform=linux/arm64 argument in repo2docker-action as such:

    - name: update jupyter dependencies with repo2docker
      uses: jupyterhub/repo2docker-action@master
      with:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
        REPO2DOCKER_EXTRA_ARGS: --Repo2Docker.platform=linux/arm64

but on the update jupyter dependencies with repo2docker step of the action I received and error because the image platform doesn't match the host platform:

  Step 2/50 : ENV DEBIAN_FRONTEND=noninteractive
  Warning: rning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
   ---> Running in b74454c1f2a4
  Removing intermediate container b74454c1f2a4
   ---> ad1affe2197d
  Step 3/50 : RUN apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*
  Warning: rning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
   ---> Running in abe671557370
  exec /bin/sh: exec format error

In attempt to resolve this error, I tried running the action on macos-14 but that isn't currently supported by repo2docker.

nicole-brewer added a commit that referenced this issue Mar 15, 2024
@nicole-brewer
Copy link
Contributor Author

I will consider pushing the local build of arm64 to be a good enough solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant