Skip to content

Commit 32167ee

Browse files
committed
Merge pull request #77 from infosiftr/any-user
Only be root when necessary, so that `--user` works
2 parents 3b91a48 + a3f8e65 commit 32167ee

8 files changed

+40
-16
lines changed

1.3/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

1.4/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

1.5/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

1.6/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

1.7/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

2.0/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

2.1/docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

docker-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ if [ "${1:0:1}" = '-' ]; then
88
fi
99

1010
# Drop root privileges if we are running elasticsearch
11-
if [ "$1" = 'elasticsearch' ]; then
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
1213
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
1314
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
14-
exec gosu elasticsearch "$@"
15+
16+
set -- gosu elasticsearch "$@"
17+
#exec gosu elasticsearch "$BASH_SOURCE" "$@"
1518
fi
1619

1720
# As argument is not related to elasticsearch,

0 commit comments

Comments
 (0)