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

fix: docker socket detection on unix #721

Merged
merged 5 commits into from
Aug 30, 2024
Merged

Conversation

mominul
Copy link
Contributor

@mominul mominul commented Aug 16, 2024

Docker Desktop on macOS creates the socket in the user's home directory from version 4.13.0.[1][2]

And the Docker team has the intention to move away from the root-owned /var/run/docker.sock

There is a option named Allow the default Docket Socket to be used (requires password) in the Docker Desktop, but the created symbolic link /var/run/docker.sock doesn't persist between OS restart or OS upgrade.

Without this patch or creating a symbolic link, macOS devs have to face the called `Result::unwrap()` on an `Err` value: Client(Init(SocketNotFoundError("/var/run/docker.sock"))) error.

I have used Cow to avoid the need of cloning the fields of Config struct. I am open to suggestion or other approaches.

Thanks!

Copy link

netlify bot commented Aug 16, 2024

Deploy Preview for testcontainers-rust ready!

Name Link
🔨 Latest commit 41bb721
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-rust/deploys/66d2158a5fc4250008e135e3
😎 Deploy Preview https://deploy-preview-721--testcontainers-rust.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DDtKey DDtKey changed the title Fix the socket not found error on macOS fix!: use socket in the user's home directory by default on macOS Aug 17, 2024
@DDtKey
Copy link
Collaborator

DDtKey commented Aug 17, 2024

Thank you @mominul for the contribution and detailed description! 🚀
I've left couple of comments

@DDtKey DDtKey added this to the 0.22.0 milestone Aug 25, 2024
@DDtKey
Copy link
Collaborator

DDtKey commented Aug 25, 2024

Hi @mominul 👋
I'm just wondering if you're going to take a look at comments and probably implement the changes? (No pressure at all, trying understand the state).
Perhaps we will extract suggested changes into separate PR if you don't have time

Thank you one more time!

@mominul
Copy link
Contributor Author

mominul commented Aug 25, 2024

Hello @DDtKey!

Sorry for the delay in implementing the changes; I'll try to implement them by next week.

Thanks! 😄

@mominul
Copy link
Contributor Author

mominul commented Aug 30, 2024

@DDtKey I have addressed your suggestions, can you have a look at it please?

testcontainers/src/core/env/config.rs Outdated Show resolved Hide resolved
testcontainers/src/core/env/config.rs Outdated Show resolved Hide resolved
testcontainers/src/core/env/config.rs Outdated Show resolved Hide resolved
testcontainers/src/core/env/config.rs Outdated Show resolved Hide resolved
Remove the user id dependent fallback socket path
@mominul
Copy link
Contributor Author

mominul commented Aug 30, 2024

@DDtKey Can you have another look at this, please? I have removed the user id dependent socket path fallback until we get demand to add it.

@DDtKey DDtKey changed the title fix!: use socket in the user's home directory by default on macOS fix!: docker socket detection on unix Aug 30, 2024
Copy link
Collaborator

@DDtKey DDtKey left a comment

Choose a reason for hiding this comment

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

Thank you a lot for the contribution! 🙏

@DDtKey DDtKey enabled auto-merge (squash) August 30, 2024 18:56
@DDtKey DDtKey changed the title fix!: docker socket detection on unix fix: docker socket detection on unix Aug 30, 2024
@DDtKey DDtKey merged commit 202ec4a into testcontainers:main Aug 30, 2024
12 checks passed
@github-actions github-actions bot mentioned this pull request Aug 30, 2024
DDtKey pushed a commit that referenced this pull request Aug 30, 2024
## 🤖 New release
* `testcontainers`: 0.21.1 -> 0.22.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.22.0] - 2024-08-30

### Details
#### Bug Fixes
- [❗] Docker socket detection on unix
([#721](#721))

#### Features
- Add `working_dir` to `ContainerRequest`,`ImageExt`
([#724](#724))

#### Miscellaneous Tasks
- Added `#![forbid(unsafe_code)]` to the library
([#722](#722))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants