bazel-remote
bazel-remote copied to clipboard
How do I customize the HTTP port?
Description
The docs in the README say the following:
--http_address value Address specification for the HTTP server listener,
formatted either as [host]:port for TCP or unix://path.sock for Unix
domain sockets. [$BAZEL_REMOTE_HTTP_ADDRESS]
--host value DEPRECATED. Use --http_address to specify the HTTP server
listener. [$BAZEL_REMOTE_HOST]
--port value DEPRECATED. Use --http_address to specify the HTTP server
listener. (default: 8080) [$BAZEL_REMOTE_PORT]
So I tried something like this with the latest release as of this writing:
docker run \
--rm \
--env BAZEL_REMOTE_HTTP_ADDRESS=":9090" \
--env BAZEL_REMOTE_MAX_SIZE=100 \
-p 9090:9090 \
quay.io/bazel-remote/bazel-remote:v2.5.1@sha256:37c9bf6a9c1763b0301882f2cb20a9d4cf54b46164e621cf6645bdbcc445acd4
I'd expected to see the HTTP server running on port 9090 in the container, but see this in logs:
2025/06/05 14:06:03 Starting HTTP server on address :8080
And sure enough, the service is not available on :9090.
curl --fail http://127.0.0.1:9090/status
# curl: (56) Recv failure: Connection reset by peer
If I switch to hitting port 8080 on the container, the service is available there, so that's not just a misleading log message.
docker run \
--rm \
--env BAZEL_REMOTE_HTTP_ADDRESS=":9090" \
--env BAZEL_REMOTE_MAX_SIZE=100 \
-p 8080:8080 \
quay.io/bazel-remote/bazel-remote:v2.5.1@sha256:37c9bf6a9c1763b0301882f2cb20a9d4cf54b46164e621cf6645bdbcc445acd4
curl --fail http://127.0.0.1:8080/status
{
"CurrSize": 0,
"UncompressedSize": 0,
"ReservedSize": 0,
"MaxSize": 107374182400,
"NumFiles": 0,
"ServerTime": 1749132479,
"GitCommit": "d0f166cdd973342ec4aa8a51228cfd3a7a205414",
"NumGoroutines": 9
}
How do I customize the HTTP address when running a container with quay.io/bazel-remote/bazel-remote?
At first I thought that there was not an existing issue that captures this, but maybe it is the same as #736?
Following that report, it looks like maybe a command-line flag setting --http-address is baked into the image's entrypoint, and that causes the environment variable to be ignored?
https://github.com/buchgr/bazel-remote/blob/7f72df6ffb0913a753afa8ea3db16a54591c7493/BUILD.bazel#L109
Hi, if you're using docker I think the easiest thing to do is tell docker to map host ports to container ports (and leave the internal ports used by bazel-remote inside the container unchanged). The README.md file has an example which uses: -p 9090:8080 -p 9092:9092, which tells docker to remap port 8080 (http) and 9092 (grpc) inside the container to 9090 and 9092 on the host side.
Thanks, right I understand that I can map any port on the host to 8080 on the container, and doing so isn't a problem. I'm not running any other processes inside that container that contend for port 8080, so I'll just do that in my deployments.
I was just surprised that setting BAZEL_REMOTE_HTTP_ADDRESS was not, by itself, enough to change the port inside the container. I'd assumed that docker run with no command set would run with all the default values, and that I could override those values by environment variables alone.
If you don't want to support that, fine with me to close this issue. You could probably close #736 too, as I realized after opening this that it's probably asking for the same thing.
Thanks for this great project, besides this slight confusion it was super easy to set up and use!
I'm not a docker expert, but I think you always need to expose ports with the -p flag, so there doesn't seem to be much benefit in changing the internal port. In which case it seems simpler to keep the internal port configuration fixed and just control it on the docker command line.
However, I notice that we don't currently do this for the grpc port- it's probably worth doing that for consistency, and we should mention this in the docker section of README.md to avoid confusion.
Thanks for this great project, besides this slight confusion it was super easy to set up and use!
Thanks for the feedback :)