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

Support rootless docker. #890

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Support rootless docker. #890

merged 1 commit into from
Jul 1, 2022

Conversation

Alexhuszagh
Copy link
Contributor

@Alexhuszagh Alexhuszagh commented Jul 1, 2022

Adds support for rootless docker, and manually overriding rootless/rootful container engines through the CROSS_ROOTLESS_CONTAINER_ENGINE environment variable. If not set, it will use the default mode for the container engine (rootful for docker, rootless for everything else).

# use the defaults
cross run ...
# auto-select if using rootless (the default)
CROSS_ROOTLESS_CONTAINER_ENGINE=auto cross run ...
# always use rootful mode
CROSS_ROOTLESS_CONTAINER_ENGINE=0 cross run ...
# always use rootless mode
CROSS_ROOTLESS_CONTAINER_ENGINE=1 cross run ...

Closes #889.

@Alexhuszagh Alexhuszagh added enhancement A-container-engine Area: container engines labels Jul 1, 2022
@Alexhuszagh Alexhuszagh added this to the v0.2.3 milestone Jul 1, 2022
@Alexhuszagh Alexhuszagh requested a review from a team as a code owner July 1, 2022 04:45
@Alexhuszagh Alexhuszagh force-pushed the rootless branch 2 times, most recently from 7297d0d to c07045f Compare July 1, 2022 05:34
src/docker/shared.rs Outdated Show resolved Hide resolved
@Alexhuszagh Alexhuszagh force-pushed the rootless branch 2 times, most recently from 7946650 to 169f5a2 Compare July 1, 2022 06:13
src/docker/shared.rs Show resolved Hide resolved
@Alexhuszagh Alexhuszagh force-pushed the rootless branch 2 times, most recently from 091dd87 to 86e9f83 Compare July 1, 2022 06:37
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

one thing I just realised is that we have config::Environment, we should probably convert all our special case stuff to be in there sometime. This is fine though

CHANGELOG.md Show resolved Hide resolved
Adds support for rootless docker, and manually overriding
rootless/rootful container engines through the
`CROSS_ROOTLESS_CONTAINER_ENGINE` environment variable. If not set, it
will use the default mode for the container engine (rootful for docker,
rootless for everything else).

```bash
\# use the defaults
cross run ...
\# auto-select if using rootless (the default)
CROSS_ROOTLESS_CONTAINER_ENGINE=auto cross run ...
\# always use rootful mode
CROSS_ROOTLESS_CONTAINER_ENGINE=0 cross run ...
\# always use rootless mode
CROSS_ROOTLESS_CONTAINER_ENGINE=1 cross run ...
```

Closes cross-rs#889.
@Alexhuszagh
Copy link
Contributor Author

one thing I just realised is that we have config::Environment, we should probably convert all our special case stuff to be in there sometime. This is fine though

That would also be good, since we could move bool_from_envvar and other logic there as well, and then provide bool_or_default or something. Something like:

fn bool_or_default(var: &str) -> bool {
    env::var(var)
        .map(|s| bool_from_envvar(&s))
        .unwrap_or_default()
}

And this would cover basically every case.

@Alexhuszagh
Copy link
Contributor Author

bors r=Emilgardis

@bors
Copy link
Contributor

bors bot commented Jul 1, 2022

Build succeeded:

@bors bors bot merged commit 9c30394 into cross-rs:main Jul 1, 2022
@Alexhuszagh Alexhuszagh deleted the rootless branch July 1, 2022 07:26
github-merge-queue bot pushed a commit that referenced this pull request Dec 17, 2023
…ootless?" (#1380)

I recently encountered #1098 and propose an iteration on the fix in #890

This patch adds a last minute check that looks up the current builder
endpoint. This may be seen as a costly operation however, as mentioned
in #889

Here's the output of `docker builder inspect` on my rootless install:
```
Name:          rootless
Driver:        docker
Last Activity: 2023-12-03 02:04:14 +0000 UTC

Nodes:
Name:      rootless
Endpoint:  rootless  # <= THIS HERE
Status:    running
Buildkit:  v0.11.7+d3e6c1360f6e
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
Labels:
 org.mobyproject.buildkit.worker.moby.host-gateway-ip: 172.17.0.1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-container-engine Area: container engines enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Rootless Docker
2 participants