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 for non-default docker host added #16477

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

davidsanfal
Copy link
Contributor

@davidsanfal davidsanfal commented Jun 13, 2024

Changelog: Fix: Add support for non default docker hosts in conan runners
Docs: Omit

@davidsanfal davidsanfal linked an issue Jun 13, 2024 that may be closed by this pull request
Copy link
Member

@AbrilRBS AbrilRBS left a comment

Choose a reason for hiding this comment

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

This works for me now :)

@AbrilRBS AbrilRBS added this to the 2.5.0 milestone Jun 14, 2024
self.docker_client = docker.DockerClient(base_url=base_url, version='auto')
break
except:
continue
Copy link
Member

Choose a reason for hiding this comment

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

If every try fails, we could have a pretty error for the user in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, we rise this exception:

raise ConanException("Docker Client failed to initialize."
                     "\n - Check if docker is installed and running"
                     "\n - Run 'pip install conan[runners]'")

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

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

Looks good to me if it works, just some potential readability minor issues.

Comment on lines 71 to 77
docker_base_urls = [
os.environ.get('CONAN_RUNNER_DOCKER_HOST'),
os.environ.get('DOCKER_HOST'),
'unix:///var/run/docker.sock',
f'unix://{os.path.expanduser("~")}/.rd/docker.sock'
]
for base_url in docker_base_urls:
Copy link
Member

Choose a reason for hiding this comment

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

Sounds a bit hacky, some suggestions:

  • Add some comment explaining the why. Explain the different URLs a bit
  • Is it possible to unify the above docker.from_env() and this call in a single one? so trying to connect the docker client looks like less like a workaround hack?

@memsharded memsharded modified the milestones: 2.5.0, 2.6.0 Jul 1, 2024
self.docker_api = self.docker_client.api
docker_base_urls = [
None, # Default docker configuration, let the python library detect the socket
os.environ.get('CONAN_RUNNER_DOCKER_HOST'), # Connect to socket defined in CONAN_RUNNER_DOCKER_HOST
Copy link
Member

Choose a reason for hiding this comment

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

But why CONAN_RUNNER_DOCKER_HOST? This is not something defined by Rancher or anyone else, I suggest removing and leaving DOCKER_HOST if that is a "standard" docker env-var.

Comment on lines 74 to 76
for base_url in docker_base_urls:
try:
self.docker_client = docker.DockerClient(base_url=base_url, version='auto')
Copy link
Member

Choose a reason for hiding this comment

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

Some info message, maybe at least ConanOutput().verbose() of the things that are being tried would make sense.

@memsharded memsharded modified the milestones: 2.6.0, 2.5.0 Jul 2, 2024
@AbrilRBS
Copy link
Member

AbrilRBS commented Jul 2, 2024

Confirmed that I can now run ny own docker images from rancher without problems now :)

@AbrilRBS AbrilRBS merged commit 2db8976 into conan-io:develop2 Jul 2, 2024
2 checks passed
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.

[bug] Docker runner issues with Docker Rancher
3 participants