@@ -19,13 +19,14 @@ automatically published to these public registries for every tagged release:
1919- [ mccutchen/go-httpbin] [ docker-hub ]
2020
2121``` bash
22- # Run http server
2322$ docker run -P ghcr.io/mccutchen/go-httpbin
24-
25- # Run https server
26- $ docker run -e HTTPS_CERT_FILE=' /tmp/server.crt' -e HTTPS_KEY_FILE=' /tmp/server.key' -p 8080:8080 -v /tmp:/tmp ghcr.io/mccutchen/go-httpbin
2723```
2824
25+ > [ !NOTE]
26+ > Prebuilt image versions >= 2.19.0 run as a non-root user by default. See
27+ > [ Configuring non-root docker images] ( #configuring-non-root-docker-images )
28+ > below for details.
29+
2930### Kubernetes
3031
3132```
@@ -109,10 +110,9 @@ variables (or a combination of the two):
109110| ` -srv-read-timeout ` | ` SRV_READ_TIMEOUT ` | Value to use for the http.Server's ReadTimeout option | 5s |
110111| ` -use-real-hostname ` | ` USE_REAL_HOSTNAME ` | Expose real hostname as reported by os.Hostname() in the /hostname endpoint | false |
111112
112- #### ⚠️ ** HERE BE DRAGONS** ⚠️
113-
114- These configuration options are dangerous and/or deprecated and should be
115- avoided unless backwards compatibility is absolutely required.
113+ > [ !WARNING]
114+ > These configuration options are dangerous and/or deprecated and should be
115+ > avoided unless backwards compatibility is absolutely required.
116116
117117| Argument| Env var | Documentation | Default |
118118| - | - | - | - |
@@ -123,6 +123,35 @@ avoided unless backwards compatibility is absolutely required.
123123- See [ Production considerations] for recommendations around safe configuration
124124 of public instances of go-httpbin
125125
126+ #### Configuring non-root docker images
127+
128+ Prebuilt image versions >= 2.19.0 run as a non-root user by default to improve
129+ container security at the cost of additional complexity for some non-standard
130+ deployments:
131+
132+ - To run the go-httpbin image a) on a privileged port (i.e. below 1024) _ and_
133+ b) using the Docker host network, you may need to run the container as root
134+ in order to enable the ` CAP_NET_BIND_SERVICE ` capability:
135+
136+ ``` bash
137+ $ docker run \
138+ --network host \
139+ --user root \
140+ --cap-drop ALL \
141+ --cap-add CAP_NET_BIND_SERVICE \
142+ ghcr.io/mccutchen/go-httpbin \
143+ /bin/go-httpbin -port=80
144+ ```
145+
146+ - If you enable HTTPS directly in the image, make sure that the certificate
147+ and private key files are readable by the user running the process:
148+
149+ ``` bash
150+ $ chmod 644 /tmp/server.crt
151+ $ chmod 640 /tmp/server.key
152+ # GID 65532: primary group of the nonroot user in distroless/static:nonroot.
153+ $ chown root:65532 /tmp/server.crt /tmp/server.key
154+ ```
126155
127156## Installation
128157
0 commit comments