Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

feat: Mount to correct DOCKER_HOST#959

Merged
dbarrosop merged 4 commits into
nhost:mainfrom
Nikhil-42:main
May 30, 2025
Merged

feat: Mount to correct DOCKER_HOST#959
dbarrosop merged 4 commits into
nhost:mainfrom
Nikhil-42:main

Conversation

@Nikhil-42
Copy link
Copy Markdown
Contributor

Description

Problem

Currently the docker.sock path is hardcoded when generating the volumes for the traefik container in the docker-compose.yml file generation.

Solution

Checks the DOCKER_HOST environment variable for the active socket location, if it doesn't exist the CLI defaults to /var/run/docker.sock (no change), if it does exist and is a unix: socket, then mount the appropriate file. If it does exist and is not a unix: socket, throw an error.

Notes

This helps resolve #727 because Podman relies on the DOCKER_HOST environment variable when using the rootless socket.

Comment thread dockercompose/compose.go Outdated
@dbarrosop
Copy link
Copy Markdown
Member

Thanks a lot for the PR, I proposed a suggestion that I think will make the code slightly cleaner and more resilient to weird DOCKER_HOST values.

@Nikhil-42 Nikhil-42 requested a review from dbarrosop May 17, 2025 07:05
Nikhil-42 and others added 2 commits May 17, 2025 03:07
Co-authored-by: David Barroso <dbarrosop@dravetech.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the traefik service configuration to mount the correct Docker socket based on the DOCKER_HOST environment variable.

  • Introduces logic to check and parse the DOCKER_HOST variable
  • Updates the volume source in docker-compose configuration accordingly

Comment thread dockercompose/compose.go Outdated
return nil, fmt.Errorf("failed to parse DOCKER_HOST: %w", err)
}
if u.Scheme != "unix" {
return nil, fmt.Errorf("unsupported scheme %s in DOCKER_HOST, only unix supported", protocol)
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The error message uses the variable 'protocol', which is undefined. It should use 'u.Scheme' instead.

Suggested change
return nil, fmt.Errorf("unsupported scheme %s in DOCKER_HOST, only unix supported", protocol)
return nil, fmt.Errorf("unsupported scheme %s in DOCKER_HOST, only unix supported", u.Scheme)

Copilot uses AI. Check for mistakes.
@dbarrosop
Copy link
Copy Markdown
Member

Thanks, unfortunately this is broken. Please, make sure it works and let me know so I can test/review again.

@Nikhil-42 Nikhil-42 requested a review from Copilot May 26, 2025 05:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the traefik service configuration to mount the Docker socket dynamically based on the DOCKER_HOST environment variable rather than relying on a hardcoded path.

  • Added support to parse DOCKER_HOST and mount the corresponding UNIX socket.
  • Introduced an error handling mechanism for non-unix socket schemes.
Comments suppressed due to low confidence (1)

dockercompose/compose.go:212

  • [nitpick] Consider renaming the variable 'path' to 'socketPath' for improved clarity regarding its purpose in representing the Docker socket path.
path := "/var/run/docker.sock"

@dbarrosop
Copy link
Copy Markdown
Member

The CI is failing due to lack of permissions to read secrets, I tested things by hand and they work so merging.

@dbarrosop dbarrosop merged commit b2f7802 into nhost:main May 30, 2025
4 of 7 checks passed
@dbarrosop
Copy link
Copy Markdown
Member

Oh, and thanks for this, of course :D

@christensenjairus
Copy link
Copy Markdown

christensenjairus commented Jun 4, 2025

@dbarrosop how would I go about using the nhost cli with rootless podman with the above changes? I saw you resolved #727 with this change, that's why I ask.

@dbarrosop
Copy link
Copy Markdown
Member

Unfortunately, I don't know, this was a community contribution. I have no means of reproducing the problem so I am unsure what the problem is. I would suggest checking the comment that lead to this PR and following up there if the latest cli doesn't work for you. Thanks!

@unmade-spangle
Copy link
Copy Markdown

unmade-spangle commented Jun 8, 2025

Why do you then complete a pull request, and link an issue as completed when you have no idea what it's about or if it resolves it?

The #727 issue mentions that nhost up doesn't work with podman installed instead of docker, and it still doesn't.

Why would you not have the means to reproduce this, or think this has now been solved then?!

@dbarrosop
Copy link
Copy Markdown
Member

Please, refer to my previous comment. Thanks!

@Nikhil-42
Copy link
Copy Markdown
Contributor Author

@unmade-spangle @christensenjairus I made this PR, if you are still having issues after following these instructions #727 (comment). Then reopen #727 and post what problems you are having. This patch works for me and my team but we are all using Arch Linux based systems. If your installation of Podman is different your mileage may vary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Podman support

5 participants