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 a rootless Docker strategy #2985

Merged
merged 17 commits into from
Jul 15, 2020
Merged

Add a rootless Docker strategy #2985

merged 17 commits into from
Jul 15, 2020

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Jul 9, 2020

Closes #2943, #1770

@bsideup bsideup added this to the next milestone Jul 9, 2020
rnorth added a commit to usmanovbf/testcontainers-java that referenced this pull request Jul 10, 2020
rnorth added a commit to usmanovbf/testcontainers-java that referenced this pull request Jul 10, 2020
@@ -21,6 +24,9 @@

@Test
public void shouldReportOOMAfterWait() {
Info info = DockerClientFactory.instance().client().infoCmd().exec();
// Poor man's rootless Docker detection :D
Copy link
Member

Choose a reason for hiding this comment

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

😂 for our tests, could we do this using the host socket URI?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't want to do string matching, especially given that the feature is experimental and may change the socket location.

Apparently, Docker returns rootless security capability from the info endpoint, just docker-java does not expose it (yet). I will add it to docker-java, so that we can remove this workaround, okay? :)

Copy link
Member

Choose a reason for hiding this comment

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

Cool, I was wondering if that would be the case. Let's not hold up this PR for the change in docker-java, though - it's OK as-is.

@Deprecated
public final class RootlessDockerClientProviderStrategy extends DockerClientProviderStrategy {

public static final int PRIORITY = EnvironmentAndSystemPropertyClientProviderStrategy.PRIORITY + 20;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to be the highest priority? I'd put this lower than UnixSocketClientProviderStrategy, at least after #1771 is merged (so that DOCKER_HOST is always respected, non-rootless-docker is tried first, and automatically configured rootless docker is tried last of all)

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't want rootless DOCKER_HOST to take precedence (because we need to override the host ip) but yeah, I see what you mean.

I will make it have lower priority, but ensure that EnvAndSysPropsStrategy does not detect rootless host that easily

Copy link
Member Author

Choose a reason for hiding this comment

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

update:
with overridable host, it is no longer a problem when EnvAndSysPropsStrategy detects the rootless DOCKER_HOST

@bsideup bsideup marked this pull request as ready for review July 12, 2020 16:23
@bsideup bsideup requested a review from kiview as a code owner July 12, 2020 16:23

However, sometimes a customization is required. For that, you can provide the following environment variables:

> **TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE = /var/run/docker-alt.sock**
Copy link
Member

Choose a reason for hiding this comment

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

Could we make these match the format of other configuration settings, where we show what the default value is?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but there is no default value, so I am not sure what to use :D

docs/features/configuration.md Show resolved Hide resolved
Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @bsideup!

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

Successfully merging this pull request may close these issues.

Rootless Docker support
2 participants