crowdsecurity / example-docker-compose

Example integration of crowdsec in docker-compose
114 stars 25 forks source link

Enable Dashboard for npm #12

Closed Puffo19 closed 11 months ago

Puffo19 commented 11 months ago

Hello,

would it be possible to enable the dashboard from crowedsec?

I added

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

to the docker-compose file from https://github.com/crowdsecurity/example-docker-compose/blob/main/npm/docker-compose.yml

Then I tried to get the dashboard setup:

cscli dashboard setup
? CrowdSec takes no responsibility for the security of your metabase instance. Do you accept these responsibilities ? Yes
? For metabase docker to be able to access SQLite file we need to add a new group called 'crowdsec' to the system, is it ok for you ? Yes
FATA[26-11-2023 15:46:02] unable to find 'groupadd' command, can't continue 

Trying to do groupadd crowdsec brings me a little step forward. But I get still an fatal error which I can't solve:

cscli dashboard setup
? CrowdSec takes no responsibility for the security of your metabase instance. Do you accept these responsibilities ? Yes
INFO[26-11-2023 15:46:52] /var/lib/crowdsec/data/metabase.db exists, skip. 
INFO[26-11-2023 15:46:52] Pulling docker image metabase/metabase:v0.46.6.1 
...
INFO[26-11-2023 15:46:53] creating container 'crowdsec-metabase'       
FATA[26-11-2023 15:46:53] container create: failed to create container : Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /var/lib/crowdsec/data

the folder exists /var/lib/crowdsec/data in the docker container. What can solve this problem?

LaurenceJJones commented 11 months ago

Running cscli dashboard setup from within the container is not supported as you need to mount multiple directories that need to be mounted to host. (Hence the error you are seeing, the host cannot see the container /var/lib/crowdsec/data folder)

You can see how to run a separate image from the basic example just adapt it to your needs.

https://github.com/crowdsecurity/example-docker-compose/blob/fd866daaa2dd73699a2e77fdc86973650d803d7a/basic/docker-compose.yml#L53-L68

Puffo19 commented 11 months ago

Thanks a lot. Thats helps me for the next steps.