Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: allow for different docker socket path in docker-based templates (#15035) #15049

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

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

phorcys420
Copy link
Member

@phorcys420 phorcys420 commented Oct 12, 2024

This PR fixes #15035, I have tested it on my instance and it works as expected.

I have opted to default to null, that way we don't have to hardcode our own default and we let the Docker provider default to whatever it wants.
This has the downside that it makes the template a little less readable, but it has the upside that we don't have to update the default if for some reason it ever changes.

We could also do something like this, but I like it less.

variable "docker_socket" {
  default     = "unix:///var/run/docker.sock"
  description = "Docker socket URI"
  type        = string
}

provider "docker" {
  host = var.docker_socket
}

I have not edited the templates that are not present in examples/templates (namely examples/jfrog/docker and examples/parameters), should I also edit these as well?
Maybe we would also want to move them to examples/templates in a separate PR?


NOTE: this PR does not cover using authenticated sources, so it's likely that only unix and tcp sockets would work out of the box but I think we don't want to include authenticated sockets OOTB (e.g SSH) because that would overcomplicate the template.

cc: @matifali

@phorcys420
Copy link
Member Author

(behavior when an invalid Docker socket is inputted)
image


(behavior when a valid Docker socket is inputted)
image

@phorcys420 phorcys420 changed the title fix: allow for different docker socket path in docker-based templates (#15035) feat: allow for different docker socket path in docker-based templates (#15035) Oct 12, 2024
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

This brings the template motion line with the kubernetes starter template 👍

@matifali
Copy link
Member

How will it work for ssh docker hosts? Have you tested?

@phorcys420 phorcys420 merged commit 79d24d2 into main Oct 12, 2024
30 checks passed
@phorcys420 phorcys420 deleted the docker-socket-variable branch October 12, 2024 19:35
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2024
@phorcys420
Copy link
Member Author

How will it work for ssh docker hosts? Have you tested?

@matifali I have not tested it but when using SSH hosts you always have to either trust the host or disable host checking.
you also need to have a valid public key on the remote host but theoretically it should work OOTB if you trust the host beforehand and have a valid key.

see https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs#remote-hosts

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

Successfully merging this pull request may close these issues.

Add a variable to ask for socket in Docker-based example templates
3 participants