Skip to content

TODO: add a dev note regarding sudoless docker #749

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

Closed
Tranquility2 opened this issue Dec 14, 2024 · 8 comments · Fixed by #750
Closed

TODO: add a dev note regarding sudoless docker #749

Tranquility2 opened this issue Dec 14, 2024 · 8 comments · Fixed by #750

Comments

@Tranquility2
Copy link
Contributor

Devs should be informed (using the official docs) that the testing environment considers sudoless docker as a baseline (and some things might not work / break if sudo is required)

For a future plan, we should rewrite / avoid using docker command directly (for example using subprocess.run) and use the docker SDK.

@Tranquility2
Copy link
Contributor Author

Image
This is the general gist

@Tranquility2
Copy link
Contributor Author

@alexanderankin @totallyzen please tell me how you think is best to proceed and I'll open a PR accordingly.

@alexanderankin
Copy link
Member

what did you do that didnt work? for example, i just pulled latest main, ran tests with make tests, expected that to work and it did. Well, I'm still waiting - currently it is running aws, core/arango succeeded.

@Tranquility2
Copy link
Contributor Author

Checkout the comments on https://github.com/testcontainers/testcontainers-python/pull/714/files#r1885389659
TLDR: the dind tests fails as they run "docker build" without sudo using subprocess.

@Tranquility2
Copy link
Contributor Author

I assume you prefer not to add this comment so I'll start working on replacing the relevant code.

@Tranquility2
Copy link
Contributor Author

@alexanderankin
Copy link
Member

ah okay so "sudoless" refers not to rootless docker or anything but rather it refers to the permissions on the docker socket.

I consider it invalid docker installation if you do not also do

sudo usermod -aG docker $USER

after installing.

I wonder what the difference is between using DockerClient() - as I've instructed people to do the usermod and that has unblocked people using testcontainers in general before on linux (via slack).

@Tranquility2
Copy link
Contributor Author

Tranquility2 commented Dec 15, 2024

Note that its not the user that affect the behavior but the complimentary requirement
export DOCKER_HOST=unix:///run/user/1000/docker.sock source
This can be avoided as the DockerClient fetch the DOCKER_HOST and make our life easier without the need to rely on/in case docker is running with/without sudo :)

alexanderankin pushed a commit that referenced this issue Dec 15, 2024
fix: #749

Replace using `subprocess.run` in the **dind** test with SDK to avoid
the direct call to docker that enforces the developer to run _sudoless_
docker.
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.

2 participants