Skip to content

Commit 7fb0c31

Browse files
committed
2025-03-05 Chronograf - old-menu branch - PR 2 of 2
[PR 781](influxdata/influxdata-docker#781) was submitted on 2025-01-21 but is has now been over 40 days without any response. It isn't clear whether it is simply taking the time it needs to take, or if this is a signal that it will never be processed. The basic problem occurs with Docker "bind mounts" which are the convention for IOTstack containers. If Chronograf launches from a clean slate, Docker will create `./volumes/chronograf` with root ownership. Although the container *launches* as root, it does not take the opportunity to enforce its ownership conventions prior to downgrading its privileges to that of (internal) user `chronograf` (ID=999). The result is the container can't write to its persistent store, crashes and goes into a restart loop. This PR provides an augmented entry point script which sets ownership correctly prior to launching the `chronograf` process. This PR applies the patch for IOTstack users via a local Dockerfile. It can be unwound if/when PR781 is processed. Signed-off-by: Phill Kelley <[email protected]>
1 parent dae8223 commit 7fb0c31

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

.templates/chronograf/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM chronograf:alpine
2+
3+
# see https://github.com/influxdata/influxdata-docker/pull/781
4+
# this patch can be withdrawn if/when PR781 is applied.
5+
6+
COPY entrypoint.sh /entrypoint.sh
7+
8+
# EOF

.templates/chronograf/entrypoint.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ "${1:0:1}" = '-' ]; then
5+
set -- chronograf "$@"
6+
fi
7+
8+
if [ "$1" = 'chronograf' ]; then
9+
export BOLT_PATH=${BOLT_PATH:-/var/lib/chronograf/chronograf-v1.db}
10+
fi
11+
12+
if [ $(id -u) -eq 0 ] ; then
13+
if [ "${CHRONOGRAF_AS_ROOT}" != "true" ] ; then
14+
chown -Rc chronograf:chronograf /var/lib/chronograf
15+
exec su-exec chronograf "$@"
16+
fi
17+
chown -Rc root:root /var/lib/chronograf
18+
else
19+
if [ ! -w /var/lib/chronograf ] ; then
20+
echo "You need to change ownership on chronograf's persistent store. Run:"
21+
echo " sudo chown -R $(id -u):$(id -u) /path/to/persistent/store"
22+
fi
23+
fi
24+
25+
exec "$@"

.templates/chronograf/service.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
chronograf:
22
container_name: chronograf
3-
image: chronograf:latest
3+
build:
4+
context: ./.templates/chronograf/.
45
restart: unless-stopped
56
environment:
67
- TZ=${TZ:-Etc/UTC}
@@ -10,11 +11,11 @@
1011
# - INFLUXDB_PASSWORD=
1112
# - INFLUXDB_ORG=
1213
# - KAPACITOR_URL=http://kapacitor:9092
14+
# - CHRONOGRAF_AS_ROOT=true
1315
ports:
1416
- "8888:8888"
1517
volumes:
1618
- ./volumes/chronograf:/var/lib/chronograf
1719
depends_on:
1820
- influxdb
1921
# - kapacitor
20-

0 commit comments

Comments
 (0)