Issue with netdata Docker agent. Failed to create SQLITE

Heya, I am trying to add a netdata agent with docker. Here is my Docker compose

version: '3'
services:
  netdata:
    image: netdata/netdata:stable
    container_name: netdata
    ports:
      - 19999:19999
    restart: unless-stopped
    cap_add:
      - SYS_PTRACE
    security_opt:
      - apparmor:unconfined
    volumes:
      - /home/ritzz/server/netdata/etc:/etc/netdata
      - /home/ritzz/server/netdata/lib:/var/lib/netdata
      - /home/ritzz/server/netdata/cache:/var/cache/netdata
      - /home/ritzz/server/netdata/passwd:/host/etc/passwd
      - /home/ritzz/server/netdata/group:/host/etc/group
      - /home/ritzz/server/netdata/proc:/host/proc
      - /home/ritzz/server/netdata/sys:/host/sys
      - /home/ritzz/server/netdata/os-release:/host/etc/os-release
    environment:
      - NETDATA_CLAIM_TOKEN=EDrkQaLMgy1eCqBPGUNG1-hNDeNsQc2nm3ROZwnvAGuOpZb--lWTS7Jgc9IfV2UrltdM3_FRZbkAZF8CB92UIqkbAz72rRoeVCP1QGDu0qX1XOYuZ47FXHgmAwtL2YwsgGOMfYY
      - NETDATA_CLAIM_URL=https://app.netdata.cloud
      - NETDATA_CLAIM_ROOMS=
      - PUID=0
      - PGID=0
      - TZ=Asia/Calcutta

and here’s the log:

 # : Invalid argument
2023-05-02 05:30:47: netdata FATAL : netdata : Failed to initialize SQLite
2023-05-02 05:30:47: netdata INFO  : MAIN : /usr/libexec/netdata/plugins.d/anonymous-statistics.sh 'FATAL' 'netdata:netdata' '0942@database/r:rrd_init       /22'
2023-05-02 05:30:48: netdata ERROR : MAIN : Execution of anonymous statistics script returned http code 400.
2023-05-02 05:30:48: netdata INFO  : MAIN : NETDATA SHUTDOWN: initializing shutdown with code 1...
2023-05-02 05:30:48: netdata INFO  : MAIN : /usr/libexec/netdata/plugins.d/anonymous-statistics.sh 'EXIT' 'ERROR' '-'
2023-05-02 05:30:49: netdata ERROR : MAIN : Execution of anonymous statistics script returned http code 400.
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: next: create shutdown file
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, create shutdown file - next: disable maintenance, new queries, new web requests, new streaming connections and aclk
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, disable maintenance, new queries, new web requests, new streaming connections and aclk - next: stop replication, exporters, ML training, health and web servers threads
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, stop replication, exporters, ML training, health and web servers threads - next: stop collectors and streaming threads
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, stop collectors and streaming threads - next: stop ML prediction and context threads
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, stop ML prediction and context threads - next: stop maintenance thread
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, stop maintenance thread - next: clean rrdhost database
2023-05-02 05:30:49: netdata INFO  : MAIN : RRD: cleaning up database [0 hosts(s)]...
2023-05-02 05:30:49: netdata INFO  : MAIN : NETDATA SHUTDOWN: in       0 ms, clean rrdhost database - next: prepare metasync shutdown
2023-05-02 05:30:49: netdata INFO  : MAIN : METADATA: Sending a scan host command
Creating docker group 0
addgroup: gid '0' in use
Could not add group docker with ID 0, its already there probably
Assign netdata user to docker group 0
2023-05-02 05:30:55: netdata ERROR : MAIN : Ignoring host prefix '/host': path '/host/proc' is not a virtual file system (errno 22, Invalid argument)
2023-05-02 05:30:55: netdata INFO  : MAIN : TIMEZONE: using TZ variable 'Asia/Calcutta'
2023-05-02 05:30:55: netdata INFO  : MAIN : TIMEZONE: fixed as 'Asia/Calcutta'
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: next: initialize ML
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize ML - next: initialize signals
2023-05-02 05:30:55: netdata INFO  : MAIN : SIGNAL: Enabling reaper
2023-05-02 05:30:55: netdata INFO  : MAIN : process tracking enabled.
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize signals - next: initialize static threads
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize static threads - next: initialize web server
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize web server - next: set resource limits
2023-05-02 05:30:55: netdata INFO  : MAIN : resources control: allowed file descriptors: soft = 1048576, max = 1048576
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, set resource limits - next: become daemon
2023-05-02 05:30:55: netdata INFO  : MAIN : Out-Of-Memory (OOM) score is already set to the wanted value 0
2023-05-02 05:30:55: netdata ERROR : MAIN : Cannot adjust netdata scheduling policy to batch (3), with priority 0. Falling back to nice. (errno 38, Function not implemented)
2023-05-02 05:30:55: netdata ERROR : MAIN : Cannot get my current process scheduling policy. (errno 38, Function not implemented)
2023-05-02 05:30:55: netdata INFO  : MAIN : netdata started on pid 1.
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, become daemon - next: initialize threads after fork
2023-05-02 05:30:55: netdata INFO  : MAIN : Set threads stack size to 131072 bytes
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize threads after fork - next: initialize registry
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, initialize registry - next: fork the spawn server
2023-05-02 05:30:55: netdata INFO  : MAIN : Initializing spawn client.
2023-05-02 05:30:55: netdata INFO  : MAIN : NETDATA STARTUP: in       0 ms, fork the spawn server - next: collecting system info
2023-05-02 05:30:55: netdata INFO  : MAIN : Executing /usr/libexec/netdata/plugins.d/system-info.sh
Spawn server is up.
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_NAME=Alpine Linux
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_ID=alpine
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_ID_LIKE=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_VERSION=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_VERSION_ID=3.16.4
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_OS_DETECTION=/etc/os-release
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_CONTAINER_IS_OFFICIAL_IMAGE=true
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_NAME=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_ID=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_ID_LIKE=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_VERSION=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_VERSION_ID=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_OS_DETECTION=/host/etc/os-release
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_HOST_IS_K8S_NODE=false
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_KERNEL_NAME=Linux
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_KERNEL_VERSION=5.19.0-41-generic
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_ARCHITECTURE=x86_64
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_VIRTUALIZATION=none
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_VIRT_DETECTION=none
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CONTAINER=docker
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CONTAINER_DETECTION=dockerenv
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CPU_LOGICAL_CPU_COUNT=4
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CPU_VENDOR=GenuineIntel
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CPU_MODEL=Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CPU_FREQ=3400000000
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_CPU_DETECTION=lscpu
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_TOTAL_RAM=12432912384
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_RAM_DETECTION=procfs
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_TOTAL_DISK_SIZE=10120865472512
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_SYSTEM_DISK_DETECTION=sysfs
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_INSTANCE_CLOUD_TYPE=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_INSTANCE_CLOUD_INSTANCE_TYPE=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA_INSTANCE_CLOUD_INSTANCE_REGION=unknown
2023-05-02 05:30:56: netdata INFO  : MAIN : NETDATA STARTUP: in      56 ms, collecting system info - next: initialize RRD structures
2023-05-02 05:30:56: netdata ERROR : MAIN : Failed to initialize database at /var/cache/netdata/netdata-meta.db, due to "unable to open database file"

It fails to create an SQLite from what I see. How do I fix this?

Hi @RitZz . I’m not a docker expert, but likely this seems like a permissions problem. There is a similar issue here → [Bug]: Error trying to run in Docker for first time. · Issue #14215 · netdata/netdata · GitHub there might be some more info there.

Tried that method already. I’ve tried running the container as root, gave proper chown and chgrp permission to the folders. But still facing the error

Ok, thanks. As a test, I did a similar setup, and chmod’ed the cache directory with 777 and that seemed to work. The user running netdata inside the container is 201.

But indeed even if I don’t chmod the e.g. lib directory to 777, netdata is still able to write into it. That needs some investigation, as to why just the sqlite db is having problems.

@RitZz what are these directories?

      - /home/ritzz/server/netdata/passwd:/host/etc/passwd
      - /home/ritzz/server/netdata/group:/host/etc/group
      - /home/ritzz/server/netdata/proc:/host/proc
      - /home/ritzz/server/netdata/sys:/host/sys

Have you mounted the host syfs, procfs, etc to your home dir?

Yup, Works fine after chmod 777 but not sure why or how lib works.