Skip to content

Bug: bind: address already in use when using dagger up --port #6303

Description

@sipsma

Hit this while backfilling integ test coverage for dagger up as part of CLI changes. Repro below.

Module code:

package main

import "context"

func New(ctx context.Context) *Test {
    return &Test{
        Ctr: dag.Container().
            From("python").
            WithMountedDirectory(
                "/srv/www",
                dag.Directory().WithNewFile("index.html", "hey there"),
            ).
            WithWorkdir("/srv/www").
            WithExposedPort(8000).
            WithExec([]string{"python", "-m", "http.server"}),
    }
}

type Test struct {
    Ctr *Container
}

Everything works when using --native:

sipsma@dagger_dev:~/repo/github.com/sipsma/daggerverse/test$ dagger up --native ctr
∅ dagger up ctr CANCELED [10.17s]
┃ 8000/TCP: tunnel 0.0.0.0:8000 -> cpi9mli1o4u78.b7d44b699trss.dagger.local:8000                                                                                                                                                                         
┃ Error: context canceled                                                                                                                                                                                                                                
• Cloud URL: https://dagger.cloud/runs/fc1afa30-d2e8-473c-ade3-3910adbfb046
• Engine: 3b84e1257d0d (version v0.9.4)
⧗ 11.78s ✔ 46 ∅ 8

But if I run anything with --port I get bind errors, including with --port 8000:8000 which I thought would have been the same as --native:

sipsma@dagger_dev:~/repo/github.com/sipsma/daggerverse/test$ dagger up --port 23456:8000 ctr
✘ dagger up ctr ERROR [1.62s]
┃ Error: failed to start tunnel: input:1: host.tunnel.start host to container: failed to receive listen response: rpc error: code = Unknown desc = listen tcp 0.0.0.0:23456: bind: address already in use                                                
✘ start ERROR [0.39s]
• Cloud URL: https://dagger.cloud/runs/849eceaf-86f3-4f1d-b8db-b23a31fb69b1
• Engine: 3b84e1257d0d (version v0.9.4)
⧗ 2.77s ✔ 44 ∅ 8 ✘ 2
sipsma@dagger_dev:~/repo/github.com/sipsma/daggerverse/test$ dagger up --port 8000:8000 ctr
✘ dagger up ctr ERROR [1.76s]
┃ Error: failed to start tunnel: input:1: host.tunnel.start host to container: failed to receive listen response: rpc error: code = Unknown desc = listen tcp 0.0.0.0:8000: bind: address already in use                                                 
✘ start ERROR [0.43s]
• Cloud URL: https://dagger.cloud/runs/bcd2c12b-66cb-4a0d-abcd-4236201617e5
• Engine: 3b84e1257d0d (version v0.9.4)
⧗ 3.08s ✔ 44 ∅ 8 ✘ 2

Not sure if specific to the CLI somehow or more general, but the fact that --native works and --port 8000:8000 doesn't is quite mysterious.

Activity

  1. added
    kind/bug
    on Dec 20, 2023
  2. reopened this on Feb 8, 2024
  3. sipsma commented on Feb 8, 2024

    @sipsma
    ContributorAuthor

    @kpenfound reported this started happening again on v0.9.9, reopening

  4. removed
    kind/bug
    on May 31, 2024
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