Add support for tcp:// DOCKER_HOST

The Docker daemon that I am using is running remotely, and I connect to
it via Tailscale tunnel, which means that my DOCKER_HOST is set to
tcp://100.113.182.91:2375

This change makes Dagger work with my setup. It's been running well for
me for a few weeks now, this started as https://github.com/thechangelog/changelog.com/pull/395

I think there is an opportunity to add support for ssh:// & file://,
but I am keeping this first addition small on purpose.

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
Gerhard Lazu 2021-11-22 07:12:47 +00:00 committed by Sam Alba
parent b2ecc392e5
commit c690387ae2
4 changed files with 60 additions and 0 deletions

View File

@ -30,6 +30,10 @@ import (
keyPassphrase?: dagger.#Secret @dagger(input)
}
// Connect via DOCKER_HOST, supports tcp://
// TODO: Consider refactoring to support ssh:// & even file://
host?: string @dagger(input)
// Command to execute
command: string
@ -203,6 +207,9 @@ import (
FINGERPRINT: ssh.fingerprint
}
}
if host != _|_ && ssh == _|_ {
DOCKER_HOST: host
}
}
"mount": {
if ssh != _|_ {

View File

@ -124,6 +124,10 @@ import (
keyPassphrase?: dagger.#Input & {dagger.#Secret}
}
// Connect via DOCKER_HOST, supports tcp://
// TODO: Consider refactoring to support ssh:// & even file://
host?: string @dagger(input)
// Mount local docker socket
socket?: dagger.#Stream & dagger.#Input
@ -146,6 +150,9 @@ import (
if ssh != _|_ {
"ssh": ssh
}
if host != _|_ && ssh == _|_ {
"host": host
}
if socket != _|_ {
"socket": socket
}
@ -194,6 +201,10 @@ import (
keyPassphrase?: dagger.#Input & {dagger.#Secret}
}
// Connect via DOCKER_HOST, supports tcp://
// TODO: Consider refactoring to support ssh:// & even file://
host?: string @dagger(input)
// Mount local docker socket
socket?: dagger.#Stream & dagger.#Input
@ -246,6 +257,9 @@ import (
if ssh != _|_ {
"ssh": ssh
}
if host != _|_ && ssh == _|_ {
"host": host
}
if socket != _|_ {
"socket": socket
}

View File

@ -0,0 +1,17 @@
package docker
import (
"alpha.dagger.io/dagger"
)
TestConfig: {
host: string @dagger(input)
}
TestHost: client: #Command & {
command: #"""
docker $CMD
"""#
host: TestConfig.host
env: CMD: "version"
}

View File

@ -0,0 +1,22 @@
package docker
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/random"
)
TestConfig: {
host: string @dagger(input)
}
TestHost: {
suffix: random.#String & {
seed: ""
}
run: #Run & {
name: "daggerci-test-ssh-\(suffix.out)"
ref: "hello-world"
host: TestConfig.host
}
}