terraform-provider-docker
terraform-provider-docker copied to clipboard
Support for Docker contexts
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
Look up the Docker host from Docker Context instead of DOCKER_HOST
or the hardcoded /var/run/docker.sock
. A nice bonus would be to select a context with an argument to the provider.
Potential Terraform Configuration
provider "docker" {
context = "development"
}
In my particular case I want to the provider to work with https://github.com/abiosoft/colima. For a workaround I do export DOCKER_HOST=$(docker context inspect | jq -r '.[0].Endpoints.docker.Host')
.
Yes, it should make life easy. Currently, I am using custom logic to extract the host from the selected docker context.
Does anyone know if there is a Docker API call with the Docker context information?
I've got a fork with a fix that could work but it just relies on testing the presence of a couple possible docker.sock
paths. So not very determinable.
docker context reads from the local ~/.docker/contexts/
directory so it does not have an API.
also, this is different for each of the logged-in users.
This could potentially solve https://github.com/kreuzwerker/terraform-provider-docker/issues/262 as well