Skip to content
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

docs: host_network does support Docker task port mapping #10774

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

tgross
Copy link
Member

@tgross tgross commented Jun 16, 2021

Fixes #10010


Per the discussion in #10010 (comment) this has worked fine for a quite a while but we forgot to remove the note. The other items in that comment were addressed in docs fixes in #10766 and #10724.

To demonstrate, run the following job on a machine with a second network named "public" configured:

jobspec
job "example" {
  datacenters = ["dc1"]

  group "web" {

    network {
      mode = "bridge"
      port "www" {
        to           = 8001
        host_network = "public"
      }
    }

    task "httpd" {
      driver = "docker"

      config {
        image   = "busybox:1"
        command = "httpd"
        args    = ["-v", "-f", "-p", "8001", "-h", "/local"]
        ports   = ["www"]
      }

      template {
        data        = "<html>hello, world</html>"
        destination = "local/index.html"
      }

      resources {
        cpu    = 128
        memory = 128
      }
    }
  }
}
$ nomad job run ./example.nomad
==> 2021-06-16T15:26:51-04:00: Monitoring evaluation "e9a1cdc0"
    2021-06-16T15:26:51-04:00: Evaluation triggered by job "example"
    2021-06-16T15:26:51-04:00: Evaluation within deployment: "db3499e8"
    2021-06-16T15:26:51-04:00: Allocation "b568505f" created: node "5e57b6a0", group "web"
    2021-06-16T15:26:51-04:00: Evaluation status changed: "pending" -> "complete"
==> 2021-06-16T15:26:51-04:00: Evaluation "e9a1cdc0" finished with status "complete"
==> 2021-06-16T15:26:51-04:00: Monitoring deployment "db3499e8"
  ⠦ Deployment "db3499e8" in progress...
...

$ nomad alloc status b5685
...

Allocation Addresses (mode = "bridge")
Label  Dynamic  Address
*www   yes      10.199.0.200:23377 -> 8001

$ curl 10.199.0.200:23377
<html>hello, world</html>

@tgross tgross added this to the 1.1.2 milestone Jun 16, 2021
@tgross tgross added theme/docs Documentation issues and enhancements theme/networking labels Jun 16, 2021
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM

@tgross tgross merged commit ad3070a into main Jun 17, 2021
@tgross tgross deleted the docs-host-network-port-mapping branch June 17, 2021 13:11
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/docs Documentation issues and enhancements theme/networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-Interface doesn't work if using network_mode stanza in docker driven task
2 participants