Skip to content

Commit 3b4d8bf

Browse files
committed
FAB-5700 Couchdb crashes with mounted volume
The CouchDB image has a volume at /opt/couchdb/data which it uses to store it's persistent data. If you try to attach an external volume for this and either the host path does not exist or the permissions for the host path are incorrect, CouchDB will crash and the container will fail to start. This comes down to a permissions issue coupled with "helpful" behavior from the Docker daemon. The issue is that if the host path does not exist, the Docker daemon will create the host path but will create it under the same user as the daemon is running (which is typically root). The current Dockerfile then changes the user to couchdb but now which then runs all subsequent commands as couchdb. Although a volume is created after this, permissions are not / cannot be properly set. So this fix removes the use of the USER command in the Dockerfile, changes ownership of the volume in the docker-entrypoint script and then finally uses su-exec to start CouchDB as the couchdb user Change-Id: If8ac0e34b13d447d68b99408cebcfbf93d257c0f Signed-off-by: Gari Singh <[email protected]>
1 parent 8929b24 commit 3b4d8bf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

images/couchdb/Dockerfile.in

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ RUN chmod +x /docker-entrypoint.sh \
7474
WORKDIR /opt/couchdb
7575
EXPOSE 5984 4369 9100
7676

77-
USER couchdb
78-
7977
VOLUME ["/opt/couchdb/data"]
8078

8179
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

images/couchdb/docker-entrypoint.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
4444
sleep 1
4545
fi
4646

47-
exec "$@"
47+
chown -R couchdb:couchdb /opt/couchdb/data
48+
49+
su-exec couchdb "$@"

0 commit comments

Comments
 (0)