Skip to content

Commit e92d1bd

Browse files
authored
Merge pull request hashicorp#37 from hashicorp/pr-24-slackpad
Allows for binding privileged ports as consul user.
2 parents 7926938 + a7b54ee commit e92d1bd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

0.6/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN addgroup consul && \
1414
adduser -S -G consul consul
1515

1616
# Set up certificates, our base tools, and Consul.
17-
RUN apk add --no-cache ca-certificates curl gnupg openssl && \
17+
RUN apk add --no-cache ca-certificates curl gnupg libcap openssl && \
1818
gpg --recv-keys 91A6E7F85D05C65630BEF18951852D87348FFC4C && \
1919
mkdir -p /tmp/build && \
2020
cd /tmp/build && \

0.6/docker-entrypoint.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ if [ "$1" = 'consul' ]; then
7878
# If the data or config dirs are bind mounted then chown them.
7979
# Note: This checks for root ownership as that's the most common case.
8080
if [ "$(stat -c %u /consul/data)" = '0' ]; then
81-
chown consul:consul /consul/data
81+
chown consul:consul /consul/data
8282
fi
8383
if [ "$(stat -c %u /consul/config)" = '0' ]; then
84-
chown consul:consul /consul/config
84+
chown consul:consul /consul/config
85+
fi
86+
87+
# If requested, set the capability to bind to privileged ports before
88+
# we drop to the non-root user. Note that this doesn't work with all
89+
# storage drivers (it won't work with AUFS).
90+
if [ ! -z ${CONSUL_ALLOW_PRIVILEGED_PORTS+x} ]; then
91+
setcap "cap_net_bind_service=+ep" /bin/consul
8592
fi
8693

8794
set -- gosu consul "$@"

0 commit comments

Comments
 (0)