-
Notifications
You must be signed in to change notification settings - Fork 694
How to expose ports for go_image? #309
Comments
You can compose go_image(
name = "foo",
...
)
container_image(
name = "bar",
base = ":foo",
ports = [...],
) |
But bazel run :bar target not running the container. |
This was harder to make the default for You can also invert the layer ordering to get this, e.g.: load("@io_bazel_rules_docker//go:image.bzl", GO_DEFAULT_BASE="DEFAULT_BASE")
container_image(
name = "bar",
base = GO_DEFAULT_BASE,
ports = [...],
)
go_image(
name = "foo",
base = ":bar",
...
) |
I have tried the invertion approach too. If I run I referred the generated config file, it has the And I also checked with I am not sure, what's happening, but I get a feeling that I miss some other setting. |
We don't expose network on the Docker daemon by default when a I feel like this is a mistake, particularly since you can't override it. We should be doing what we do for Another thing to beware of is that ctrl+C of the container run by bazel won't kill it. This is a longstanding Bazel bug, that I'll dig up and ping. |
here's the thread: bazelbuild/bazel#3519 |
I was running into similar problems as @chaitanya9186 when trying to run a flask app in a container locally. Now that #312 is merged, can the lang_image binaries be updated to accept a docker_run_flags argument (and pass it to the app_layer)? Based off of my brief local testing that would make the docker pick up the run flags when running `bazel run :lang_image' locally. |
I've put a PR up to add the ports option to the go_image; #462 |
lang_images have the same arguments as their corresponding lang_binary rules. The recommended way to get these additional properties is still to compose the lang_image with a container_image as indicated in the comment above. |
Given _binary and _image tackle two different types of problem (the need for a locally executable binary -v- the need to compose a container image) it seems a little odd to try and keep their parameters in absolute sync, but hey, your repo, your rules :) |
is this still an issue? please reopen if so. |
Can you explain the rationale for wanting to keep
This isn't true. |
Some key reasons:
|
Bazel run //yourimage pushes the image to your local repository and runs it. You can suppress the run by "bazel run //yourimage -- --norun" (so this would simply publish it to your local docker) then 'docker run' it using docker. Then you can run it like you would any other image, setting ports, network, etc. |
#305
The text was updated successfully, but these errors were encountered: