Skip to content

Commit bbd15dc

Browse files
committed
Chown files in /opt/couchdb only when necessary
Recursive modification of ownership and permissions in the entrypoint has been implicated in slow container startup times. This change checks the ownership first and only modifies it if necessary. It is modeled after similar changes recently applied to a number of other projects e.g. redis/docker-library-redis#166.
1 parent 87dc8d2 commit bbd15dc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

2.2.0/docker-entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ if [ "$1" = 'couchdb' ]; then
2525
fi
2626

2727
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
28-
# we need to set the permissions here because docker mounts volumes as root
29-
chown -fR couchdb:couchdb /opt/couchdb || true
28+
# Check that we own everything in /opt/couchdb and fix if necessary. We also
29+
# add the `-f` flag in all the following invocations because there may be
30+
# cases where some of these ownership and permissions issues are non-fatal
31+
# (e.g. a config file owned by root with o+r is actually fine), and we don't
32+
# to be too aggressive about crashing here ...
33+
find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
3034

3135
chmod -fR 0770 /opt/couchdb/data || true
3236

dev/docker-entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ if [ "$1" = 'couchdb' ]; then
2525
fi
2626

2727
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
28-
# we need to set the permissions here because docker mounts volumes as root
29-
chown -fR couchdb:couchdb /opt/couchdb || true
28+
# Check that we own everything in /opt/couchdb and fix if necessary. We also
29+
# add the `-f` flag in all the following invocations because there may be
30+
# cases where some of these ownership and permissions issues are non-fatal
31+
# (e.g. a config file owned by root with o+r is actually fine), and we don't
32+
# to be too aggressive about crashing here ...
33+
find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
3034

3135
chmod -fR 0770 /opt/couchdb/data || true
3236

0 commit comments

Comments
 (0)