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

Add docker options to repo2docker #1112

Closed
petersudmant opened this issue Jan 10, 2022 · 15 comments · Fixed by #1123
Closed

Add docker options to repo2docker #1112

petersudmant opened this issue Jan 10, 2022 · 15 comments · Fixed by #1123

Comments

@petersudmant
Copy link

Proposed change

Add a way to add docker options to repo2docker.

Alternative options

There are no alternate options AFIK

Who would use this feature?

The issue I am facing is a building a x86 repo2docker on an m1 mac. I think this can be done by using docker options --platform linux/amd64 however I cannot do this currently

How much effort will adding it take?

I think this shoudl be quite straightforward.

Who can do this work?

@welcome
Copy link

welcome bot commented Jan 10, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@manics
Copy link
Member

manics commented Jan 10, 2022

This should already be possible. You can pass arbitrary key-word arguments via the extra_build_kwargs Traitlets config (note the help message is incorrect, it looks like it was copied and pasted from another parameter):

extra_build_kwargs = Dict(
{},
help="""
extra kwargs to limit CPU quota when building a docker image.
Dictionary that allows the user to set the desired runtime flag
to configure the amount of access to CPU resources your container has.
Reference https://docs.docker.com/config/containers/resource_constraints/#cpu
""",
config=True,
)

These will be passed to the Docker API client which accepts a platform= argument:
https://docker-py.readthedocs.io/en/latest/api.html#module-docker.api.build

@manics manics closed this as completed Jan 10, 2022
@yuvipanda
Copy link
Collaborator

Would this mean you've to pass in something like --Repo2Docker.extra_build_kwargs platform=linux/amd64 to the commandline invocation?

@manics
Copy link
Member

manics commented Jan 10, 2022

Something like that.... I'm still searching for a good traitlets tutorial on command line args 😀

@petersudmant
Copy link
Author

petersudmant commented Jan 10, 2022 via email

@petersudmant
Copy link
Author

I feel like this should work:

jupyter-repo2docker --extra_build_kwargs platform=linux/amd64 ./

but it results in jupyter-repo2docker: error: unrecognized arguments: --extra_build_kwargs

Any ideas?

@petersudmant
Copy link
Author

@manics should I reopen this as an "issue" as there doesn't seem to be any documentation of how to get this working in repo2docker?

@manics
Copy link
Member

manics commented Jan 11, 2022

@petersudmant Did you try @yuvipanda's suggestion? If that didn't work would you mind posting on https://discourse.jupyter.org/ instead, and make it clear you need some help with using Traitlets on the command line? I don't think re-opening the issue here will help if we don't have the knowledge of Traitlets, whereas someone is more likely to know the answer on Discourse.

@petersudmant
Copy link
Author

@manics Makes good sense. I did try @yuvipanda's suggestion w/ no luck. I'll do that right now

@manics
Copy link
Member

manics commented Jan 11, 2022

@petersudmant I've just had another idea, can you try passing a config file --config CONFIG?

@manics manics reopened this Jan 11, 2022
@manics
Copy link
Member

manics commented Jan 11, 2022

Just to emphasize my lack of traitlets experience, I suspect the config may not be in place to forward the CLI args.... I thought it was automatically done when using Traitlets but maybe not?

E.g. jupyter-lab --help-all will show all configurable traitlets but repo2docker --help-all doesn't

@petersudmant
Copy link
Author

Actually, this worked!

jupyter-repo2docker --config traitlets.config.json ./

where traitlets.config.json looks like this

{
    "Repo2Docker": {
        "extra_build_kwargs":{"platform":"linux/amd64"}
    }
}

@manics
Copy link
Member

manics commented Jan 12, 2022

@petersudmant Great! Sorry for misleading you with my earlier comment.

What are your thoughts on this configuration- is a config file good enough, or do you think it (and all other configurables) should be exposed on the command line?

@yuvipanda
Copy link
Collaborator

@manics generally with traitlets I expect them to be loaded from the commandline, we should try to do that

@petersudmant
Copy link
Author

I agree w/ @yuvipanda @manics - traitlets docs suggests either option should be possible

yuvipanda added a commit to yuvipanda/repo2docker that referenced this issue Jan 26, 2022
Without this, you *always* needed a repo2docker_config.py
file to configure anything. This PR makes r2d match the
behavior of most traitlets based applications (like jupyter_server,
jupyterhub, nbconvert, etc)

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

Successfully merging a pull request may close this issue.

3 participants