Skip to content

🐞 Dagger stop running when use docker dind as a service binding #5010

Closed

Description

@wingyplus

What is the issue?

I want to use Docker as a service in Dagger. But when binding docker with service binding, the container stop running without executing any command.

I expected at least the container (Elixir container in the example) should execute elixir --version and return the result. Or if there's anything wrong, it may log something that indicate the error.

Log output

From go run .:

#1 resolve image config for docker.io/library/docker:23.0.4-dind-rootless
#1 DONE 2.2s

#2 resolve image config for docker.io/hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0
#2 DONE 0.7s

From Dagger container (registry.dagger.io/engine:v0.5.0):

time="2023-04-24T02:40:54Z" level=debug msg="session started" spanID=1c305bea8789cca0 traceID=7f366793e8b5dc8ce00251ece0ec17d9
time="2023-04-24T02:40:54Z" level=debug msg="unsupported cache type , defaulting export off" spanID=75f5f9e5452a0361 traceID=08b31aa4bc15a904a73711048d9b9106
time="2023-04-24T02:40:54Z" level=debug msg="cache exporter resolver for dagger returned nil, skipping exporter" spanID=75f5f9e5452a0361 traceID=08b31aa4bc15a904a73711048d9b9106
time="2023-04-24T02:40:56Z" level=debug msg=resolving host=registry-1.docker.io spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006
time="2023-04-24T02:40:56Z" level=debug msg="do request" host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=buildkit/v0.0-dev request.method=HEAD spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006 url="https://registry-1.docker.io/v2/library/docker/manifests/23.0.4-dind-rootless"
time="2023-04-24T02:40:56Z" level=debug msg="healthcheck completed" actualDuration="805.208µs" spanID=bd5a4f1c3e10427d timeout=30s traceID=aff580b3237f87444c0460531b52a609
time="2023-04-24T02:40:59Z" level=debug msg="fetch response received" host=registry-1.docker.io response.header.content-length=549 response.header.content-type=application/vnd.docker.distribution.manifest.list.v2+json response.header.date="Mon, 24 Apr 2023 02:40:59 GMT" response.header.docker-content-digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=97d94f38-74c0-11e4-bea4-0242ac11001b response.header.etag="\"sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a\"" response.header.ratelimit-limit="200;w=21600" response.header.ratelimit-remaining="198;w=21600" response.header.strict-transport-security="max-age=31536000" response.status="200 OK" spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006 url="https://registry-1.docker.io/v2/library/docker/manifests/23.0.4-dind-rootless"
time="2023-04-24T02:40:59Z" level=debug msg=resolved desc.digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" host=registry-1.docker.io spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" mediatype=application/vnd.docker.distribution.manifest.list.v2+json size=549 spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:2538ea1aec9be5b0e93fb9d2088a5e3af5d2ad3d7ab280d0a779fab15a541ad7" mediatype=application/vnd.docker.distribution.manifest.v2+json size=4296 spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:da5f146df7948b500b2001573b8471329eb8044c0595b1aee105b1433961919c" mediatype=application/vnd.docker.container.image.v1+json size=13711 spanID=0db54ab81774c660 traceID=f622981b876d3fe3a174069c9db24006
time="2023-04-24T02:40:59Z" level=debug msg=resolving host=registry-1.docker.io spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430
time="2023-04-24T02:40:59Z" level=debug msg="do request" host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=buildkit/v0.0-dev request.method=HEAD spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430 url="https://registry-1.docker.io/v2/library/docker/manifests/23.0.4-dind-rootless"
time="2023-04-24T02:40:59Z" level=debug msg="fetch response received" host=registry-1.docker.io response.header.content-length=549 response.header.content-type=application/vnd.docker.distribution.manifest.list.v2+json response.header.date="Mon, 24 Apr 2023 02:41:00 GMT" response.header.docker-content-digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=97d94f38-74c0-11e4-bea4-0242ac11001b response.header.etag="\"sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a\"" response.header.ratelimit-limit="200;w=21600" response.header.ratelimit-remaining="198;w=21600" response.header.strict-transport-security="max-age=31536000" response.status="200 OK" spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430 url="https://registry-1.docker.io/v2/library/docker/manifests/23.0.4-dind-rootless"
time="2023-04-24T02:40:59Z" level=debug msg=resolved desc.digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" host=registry-1.docker.io spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:d9ad5130fa11a3dc1abe42bec5cbf255b1ce02bdf710a088a1ce8b617e49870a" mediatype=application/vnd.docker.distribution.manifest.list.v2+json size=549 spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:2538ea1aec9be5b0e93fb9d2088a5e3af5d2ad3d7ab280d0a779fab15a541ad7" mediatype=application/vnd.docker.distribution.manifest.v2+json size=4296 spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430
time="2023-04-24T02:40:59Z" level=debug msg=fetch digest="sha256:da5f146df7948b500b2001573b8471329eb8044c0595b1aee105b1433961919c" mediatype=application/vnd.docker.container.image.v1+json size=13711 spanID=2d43bf3dc310aad8 traceID=3238d7b42125c07be12936e1c8c67430
time="2023-04-24T02:40:59Z" level=debug msg=resolving host=registry-1.docker.io spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3
time="2023-04-24T02:40:59Z" level=debug msg="do request" host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=buildkit/v0.0-dev request.method=HEAD spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3 url="https://registry-1.docker.io/v2/hexpm/elixir/manifests/1.14.0-erlang-24.3.4-alpine-3.16.0"
time="2023-04-24T02:40:59Z" level=debug msg="healthcheck completed" actualDuration=3.728458ms spanID=1c305bea8789cca0 timeout=30s traceID=7f366793e8b5dc8ce00251ece0ec17d9
time="2023-04-24T02:41:00Z" level=debug msg="fetch response received" host=registry-1.docker.io response.header.content-length=772 response.header.content-type=application/vnd.docker.distribution.manifest.list.v2+json response.header.date="Mon, 24 Apr 2023 02:41:00 GMT" response.header.docker-content-digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=97d94f38-74c0-11e4-bea4-0242ac11001b response.header.etag="\"sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab\"" response.header.ratelimit-limit="200;w=21600" response.header.ratelimit-remaining="198;w=21600" response.header.strict-transport-security="max-age=31536000" response.status="200 OK" spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3 url="https://registry-1.docker.io/v2/hexpm/elixir/manifests/1.14.0-erlang-24.3.4-alpine-3.16.0"
time="2023-04-24T02:41:00Z" level=debug msg=resolved desc.digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" host=registry-1.docker.io spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" mediatype=application/vnd.docker.distribution.manifest.list.v2+json size=772 spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:161437f2e1fe49f354abab2a91b4cff7fab1f405550770f4cbc350ce315c603d" mediatype=application/vnd.docker.distribution.manifest.v2+json size=1162 spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:2bb75ba5041cb2f11c0da587f998a98730cd6cc276d1ceb93f965846770bea91" mediatype=application/vnd.docker.container.image.v1+json size=2383 spanID=44f82957783fd7ee traceID=d2b1c05e9a874e9c16d8c3fa8cdcf1e3
time="2023-04-24T02:41:00Z" level=debug msg=resolving host=registry-1.docker.io spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd
time="2023-04-24T02:41:00Z" level=debug msg="do request" host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=buildkit/v0.0-dev request.method=HEAD spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd url="https://registry-1.docker.io/v2/hexpm/elixir/manifests/1.14.0-erlang-24.3.4-alpine-3.16.0"
time="2023-04-24T02:41:00Z" level=debug msg="fetch response received" host=registry-1.docker.io response.header.content-length=772 response.header.content-type=application/vnd.docker.distribution.manifest.list.v2+json response.header.date="Mon, 24 Apr 2023 02:41:01 GMT" response.header.docker-content-digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=97d94f38-74c0-11e4-bea4-0242ac11001b response.header.etag="\"sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab\"" response.header.ratelimit-limit="200;w=21600" response.header.ratelimit-remaining="198;w=21600" response.header.strict-transport-security="max-age=31536000" response.status="200 OK" spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd url="https://registry-1.docker.io/v2/hexpm/elixir/manifests/1.14.0-erlang-24.3.4-alpine-3.16.0"
time="2023-04-24T02:41:00Z" level=debug msg=resolved desc.digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" host=registry-1.docker.io spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:bfcd284f327e98adf231cad592f9629fc7adf78d7f1a5511cd451085a528eeab" mediatype=application/vnd.docker.distribution.manifest.list.v2+json size=772 spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:161437f2e1fe49f354abab2a91b4cff7fab1f405550770f4cbc350ce315c603d" mediatype=application/vnd.docker.distribution.manifest.v2+json size=1162 spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd
time="2023-04-24T02:41:00Z" level=debug msg=fetch digest="sha256:2bb75ba5041cb2f11c0da587f998a98730cd6cc276d1ceb93f965846770bea91" mediatype=application/vnd.docker.container.image.v1+json size=2383 spanID=50a0ba61b4381a15 traceID=f5622e8770e9332a9506075e6fd48dcd
time="2023-04-24T02:41:00Z" level=debug msg="session finished: <nil>" spanID=1c305bea8789cca0 traceID=7f366793e8b5dc8ce00251ece0ec17d9
time="2023-04-24T02:41:01Z" level=debug msg="healthcheck completed" actualDuration=1.358334ms spanID=bd5a4f1c3e10427d timeout=30s traceID=aff580b3237f87444c0460531b52a609

Steps to reproduce

Create new directory, run go mod init and create go source with content below:

package main

import (
	"context"
	"os"

	"dagger.io/dagger"
)

func main() {
	ctx := context.Background()

	client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
	if err != nil {
		panic(err)
	}
	defer client.Close()

	dockerCertsCA := client.CacheVolume("docker-certs-ca")
	dockerCertsClient := client.CacheVolume("docker-certs-client")

	dockerDind := client.Container().
		From("docker:23.0.4-dind-rootless").
		WithMountedCache("/certs/ca", dockerCertsCA).
		WithMountedCache("/certs/client", dockerCertsClient).
		WithEnvVariable("DOCKER_TLS_CERTDIR", "/certs")

	client.Container().
		From("hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0").
		WithServiceBinding("docker-dind", dockerDind).
	        WithMountedCache("/certs/client", dockerCertsClient).
		WithExec([]string{"elixir", "--version"}).
		Stdout(ctx)
}

And then run go run ..

SDK version

Go SDK 0.6.0

OS version

macOS 13.1 (22C65)

Activity

  1. changed the title [-]🐞 <title>[/-] [+]🐞 Dagger stop running when use docker dind as a service binding[/+] on Apr 23, 2023
  2. wingyplus commented on Apr 24, 2023

    @wingyplus
    ContributorAuthor

    Tested against Dagger v0.5.0:

    $ docker ps
    CONTAINER ID   IMAGE                              COMMAND                  CREATED          STATUS          PORTS                                       NAMES
    37578df53394   registry.dagger.io/engine:v0.5.0   "dagger-entrypoint.s…"   43 seconds ago   Up 42 seconds                                               dagger-engine-23e74c13b0f5a5d1
  3. helderco commented on Apr 24, 2023

    @helderco
    Contributor

    Hi @wingyplus, you need to add WithExec(nil) to dockerDind because it has no exec instruction. The nil will execute default entrypoint and arguments in the image.

    I'm currently working on giving a better overview and explanation of this in:

    And I'm planning on publishing a fix today that won't require that WithExec(nil) anymore:

    You can also try the TUI to get clarity on what's running:

    Let me know if adding WithExec(nil) doesn't fix it.

  4. wingyplus commented on Apr 24, 2023

    @wingyplus
    ContributorAuthor

    @helderco Thank you. It seems to work now after add WithExec(nil) and changing image to dind:

    $ go run .
    #1 resolve image config for docker.io/library/docker:23.0.4-dind
    #1 DONE 2.3s
    
    #2 resolve image config for docker.io/hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0
    #2 DONE 0.4s
    
    #2 resolve image config for docker.io/hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0
    #2 DONE 0.7s
    
    #3 importing cache manifest from dagger:10686922502337221602
    #3 DONE 0.0s
    
    #4 from hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0
    #4 resolve docker.io/hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0
    #4 resolve docker.io/hexpm/elixir:1.14.0-erlang-24.3.4-alpine-3.16.0 0.5s done
    #4 DONE 0.5s
    
    #5 service HU6CHKAHADSPO
    #5 resolve docker.io/library/docker:23.0.4-dind 0.3s done
    #5 1.714 Certificate request self-signature ok
    #5 1.715 subject=CN = docker:dind server
    #5 1.731 /certs/server/cert.pem: OK
    #5 CANCELED
    
    #6
    #0 1.422 Erlang/OTP 24 [erts-12.3.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
    #0 1.422
    #0 1.425 Elixir 1.14.0 (compiled with Erlang/OTP 24)
    #6 DONE 1.6s
    

    May I have a new question about CANCELED at layer #5, it got canceled because the main container getting stop?

  5. helderco commented on Apr 24, 2023

    @helderco
    Contributor

    Explanation for why the WithExec(nil) at:

    As for the CANCELED, @vito has more context.

  6. vito commented on Apr 24, 2023

    @vito
    Contributor

    May I have a new question about CANCELED at layer #5, it got canceled because the main container getting stop?

    Services get interrupted when they're no longer used, which currently shows up as CANCELED in the UI. It's slightly confusing but technically correct. 😅

    We'll probably improve this in the future by making the UIs more "service aware" - right now it's basically just exposing Buildkit's perspective on what's going on.

  7. wingyplus commented on Apr 24, 2023

    @wingyplus
    ContributorAuthor

    May I have a new question about CANCELED at layer #5, it got canceled because the main container getting stop?

    Services get interrupted when they're no longer used, which currently shows up as CANCELED in the UI. It's slightly confusing but technically correct. 😅

    We'll probably improve this in the future by making the UIs more "service aware" - right now it's basically just exposing Buildkit's perspective on what's going on.

    @helderco @vito Thank you, you two. I understand now what's going on here. ^^

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions