-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move "--protected-mode no" into the entrypoint instead
Since doubling up on this option will have the "latest" version win, we're safe (in the sense of an image user being able to still override it) to apply this to all invocations of the server. This change also includes the glue necessary to allow for `docker run redis --flag`, which frustrated me while I was testing this change.
- Loading branch information
Showing
6 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# first arg is `-f` or `--some-option` | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- redis-server "$@" | ||
fi | ||
|
||
# allow the container to be started with `--user` | ||
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then | ||
chown -R redis . | ||
exec gosu redis "$0" "$@" | ||
set -- gosu redis "$0" "$@" | ||
fi | ||
|
||
if [ "$1" = 'redis-server' ]; then | ||
# Disable Redis protected mode [1] as it is unnecessary in context | ||
# of Docker. Ports are not automatically exposed when running inside | ||
# Docker, but rather explicitely by specifying -p / -P. | ||
# [1] https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da | ||
shift # "redis-server" | ||
set -- redis-server --protected-mode no "$@" | ||
# if this is supplied again, the "latest" wins, so "--protected-mode no --protected-mode yes" will result in an enabled status | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# first arg is `-f` or `--some-option` | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- redis-server "$@" | ||
fi | ||
|
||
# allow the container to be started with `--user` | ||
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then | ||
chown -R redis . | ||
exec su-exec redis "$0" "$@" | ||
set -- su-exec redis "$0" "$@" | ||
fi | ||
|
||
if [ "$1" = 'redis-server' ]; then | ||
# Disable Redis protected mode [1] as it is unnecessary in context | ||
# of Docker. Ports are not automatically exposed when running inside | ||
# Docker, but rather explicitely by specifying -p / -P. | ||
# [1] https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da | ||
shift # "redis-server" | ||
set -- redis-server --protected-mode no "$@" | ||
# if this is supplied again, the "latest" wins, so "--protected-mode no --protected-mode yes" will result in an enabled status | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# first arg is `-f` or `--some-option` | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- redis-server "$@" | ||
fi | ||
|
||
# allow the container to be started with `--user` | ||
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then | ||
chown -R redis . | ||
exec gosu redis "$0" "$@" | ||
set -- gosu redis "$0" "$@" | ||
fi | ||
|
||
if [ "$1" = 'redis-server' ]; then | ||
# Disable Redis protected mode [1] as it is unnecessary in context | ||
# of Docker. Ports are not automatically exposed when running inside | ||
# Docker, but rather explicitely by specifying -p / -P. | ||
# [1] https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da | ||
shift # "redis-server" | ||
set -- redis-server --protected-mode no "$@" | ||
# if this is supplied again, the "latest" wins, so "--protected-mode no --protected-mode yes" will result in an enabled status | ||
fi | ||
|
||
exec "$@" |