Skip to content

Commit 4923332

Browse files
committed
Run as non-privileged user
1 parent 4759eb1 commit 4923332

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@ LABEL version=${APP_VERSION}
2929
LABEL description="A simple HTTP service."
3030
LABEL org.kennethreitz.vendor="Kenneth Reitz"
3131

32+
RUN useradd \
33+
--system \
34+
--shell /bin/nologin \
35+
--no-create-home \
36+
--home /opt/httpbin \
37+
httpbin
38+
3239
COPY --from=build /opt/httpbin /opt/httpbin
40+
WORKDIR /opt/httpbin
41+
3342
ADD httpbin.bash /opt/httpbin/bin
3443
RUN chmod +x /opt/httpbin/bin/httpbin.bash
35-
EXPOSE 80
44+
RUN chown --recursive httpbin /opt/httpbin
45+
EXPOSE 8080
3646
CMD ["/opt/httpbin/bin/httpbin.bash"]
47+
48+
USER httpbin

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ httpbin is a [Kenneth Reitz](http://kennethreitz.org/bitcoin) Project.
1111

1212
```sh
1313
docker pull ghcr.io/psf/httpbin
14-
docker run -p 80:80 ghcr.io/psf/httpbin
15-
```
16-
17-
Some enviroments do not allow to bind to a privileged port. To run it on a
18-
different port instead of port 80, set the environment variables as follows:
19-
20-
```sh
21-
docker run -e HTTPIN_PORT=8000 -p 8000:8000 ghcr.io/psf/httpbin
14+
docker run -p 80:8080 ghcr.io/psf/httpbin
2215
```
2316

2417
## Using `httpbin` as a Library

httpbin.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
exec /opt/httpbin/bin/gunicorn \
3-
-b ${HTTPBIN_HOST:-0.0.0.0}:${HTTPBIN_PORT:-80} \
3+
-b ${HTTPBIN_HOST:-0.0.0.0}:${HTTPBIN_PORT:-8080} \
44
-k gevent \
55
httpbin:app

0 commit comments

Comments
 (0)