-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support custom docker daemon args #8435
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8435 +/- ##
==========================================
+ Coverage 10.03% 10.82% +0.79%
==========================================
Files 24 18 -6
Lines 1944 1025 -919
==========================================
- Hits 195 111 -84
+ Misses 1742 912 -830
+ Partials 7 2 -5
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
First of all, thanks for the great PR.
|
"remap-user": "userns-remap", | ||
} | ||
|
||
func setUserArgs(args []string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seemed simpler if it was dedicated to crate args from env vars from the user that were converted to dockerd args. In other words, instead of doing both generation and addition, why not just concentrate on generation?
func setUserArgs(args []string) ([]string, error) { | |
func userArgs() ([]string, error) { | |
args := []string{} |
And,
uargs, err := userArgs()
if err != nil {
return xerrors.Errorf("cannot add user supplied docker args: %w", err)
}
args = append(args, uargs...)
if id != 0 { | ||
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 1, id)) | ||
newfile.WriteString("gitpod:33333:1\n") | ||
|
||
} else { | ||
newfile.WriteString("gitpod:33333:1\n") | ||
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 1, 33332)) | ||
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 33334, 32200)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this? I couldn't get the point what 32200
mean. What does it mean?
if id != 0 { | |
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 1, id)) | |
newfile.WriteString("gitpod:33333:1\n") | |
} else { | |
newfile.WriteString("gitpod:33333:1\n") | |
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 1, 33332)) | |
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 33334, 32200)) | |
} | |
gitpodUserId := 33333 | |
mappingFmt := func(username string, id int, size int) string { return fmt.Sprintf("%s:%d:%d\n", username, id, size) } | |
if id != 0 { | |
newfile.WriteString(mappingFmt("gitpod", 1, id)) | |
newfile.WriteString(mappingFmt("gitpod", gitpodUserId, 1)) | |
} else { | |
newfile.WriteString(mappingFmt("gitpod", gitpodUserId, 1)) | |
newfile.WriteString(mappingFmt("gitpod", 1, gitpodUserId-1)) | |
newfile.WriteString(mappingFmt("gitpod", gitpodUserId+1, 33200)) | |
} |
I agree with you, we have to add the documentation. But I don't know too 😭
|
- Configurable runc version - Change env name - Converter func for user args
@utam0k PTAL |
Hey @mikenikles , if we wanted to document a new capability to our |
We don't have a page specifically for docker in workspaces, but could add one in the Configure section. Alternatively, I'd add a note to https://www.gitpod.io/docs/environment-variables#user-specific-environment-variables given this PR introduces a new user-level environment variable. The corresponding source file is at https://github.com/gitpod-io/website/blob/main/gitpod/docs/environment-variables.md. |
I did not try to verify which specific change in runc made the difference, although I have some suspicions. |
@@ -191,25 +196,18 @@ func setUserArgs(args []string) ([]string, error) { | |||
} | |||
|
|||
for userArg, userValue := range providedDockerArgs { | |||
mapped, exists := allowedDockerArgs[userArg] | |||
converter, exists := allowedDockerArgs[userArg] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this name 👍
newfile.WriteString(fmt.Sprintf("gitpod:%d:%d\n", 33334, 32200)) | ||
newfile.WriteString(mappingFmt("gitpod", gitpodUserId, 1)) | ||
newfile.WriteString(mappingFmt("gitpod", 1, gitpodUserId-1)) | ||
newfile.WriteString(mappingFmt("gitpod", gitpodUserId+1, 32200)) // map rest of user ids in the user namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good comment. Thanks.
map rest of user ids in the user namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯
too many commit 😂 |
got permission denied at step 5,
the
Any settings I am missing? |
@shaoye Thanks for your report. Can I ask you to make sure how under |
same, still got permission error if I mount /workspace/tmp/me
|
@shaoye Thanks! Can I ask you to create the issue? If you create it, we can schedule the issue. |
@shaoye Thank you! |
Description
This allows users to add arguments to the docker daemon running in the workspace. As a first step mapping the container user to the gitpod user is supported.
Related Issue(s)
Fixes #8103
How to test
DOCKER_DARGS
to your user settings. The content should look like this:{ "remap-user": "1000" }
(Means container id 1000 will be mapped to gitpod user).sudo docker run -it -u node -v /tmp/me:/tmp node sh
Hints for reviewers
Release Notes
Documentation
Have not added documentation before, so any advice is appreciated.