Skip to content

Commit 1107cae

Browse files
committed
Adjust entrypoint to change logs directory owner at runtime
1 parent 1a539d2 commit 1107cae

File tree

7 files changed

+49
-14
lines changed

7 files changed

+49
-14
lines changed

1.7/alpine/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- su-exec elasticsearch "$@"
1722
#exec su-exec elasticsearch "$BASH_SOURCE" "$@"

1.7/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- gosu elasticsearch "$@"
1722
#exec gosu elasticsearch "$BASH_SOURCE" "$@"

2.4/alpine/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- su-exec elasticsearch "$@"
1722
#exec su-exec elasticsearch "$BASH_SOURCE" "$@"

2.4/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- gosu elasticsearch "$@"
1722
#exec gosu elasticsearch "$BASH_SOURCE" "$@"

5/alpine/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- su-exec elasticsearch "$@"
1722
#exec su-exec elasticsearch "$BASH_SOURCE" "$@"

5/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- gosu elasticsearch "$@"
1722
#exec gosu elasticsearch "$BASH_SOURCE" "$@"

docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fi
1010
# Drop root privileges if we are running elasticsearch
1111
# allow the container to be started with `--user`
1212
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13-
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14-
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
13+
# Change the ownership of user-mutable directories to elasticsearch
14+
for path in \
15+
/usr/share/elasticsearch/data \
16+
/usr/share/elasticsearch/logs \
17+
; do
18+
chown -R elasticsearch:elasticsearch "$path"
19+
done
1520

1621
set -- gosu elasticsearch "$@"
1722
#exec gosu elasticsearch "$BASH_SOURCE" "$@"

0 commit comments

Comments
 (0)