Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker local_api_credentials.yaml being re-created at startup #3437

Closed
Kornelius777 opened this issue Jan 31, 2025 · 3 comments
Closed

docker local_api_credentials.yaml being re-created at startup #3437

Kornelius777 opened this issue Jan 31, 2025 · 3 comments
Labels
kind/bug Something isn't working needs/triage

Comments

@Kornelius777
Copy link

What happened?

My machines run crowdsec in a multi-server setup.

Now, for the first time, I wanted to try a docker deployment.

The relevant part of my docker-compose.yml looks like:

  crowdsec:
    image: crowdsecurity/crowdsec
    hostname: crowdsec
    container_name: crowdsec
    environment: 
      COLLECTIONS: "crowdsecurity/nginx"
    depends_on:
      - nginx
    volumes:
      - /docker/crowdsec:/etc/crowdsec
      - /docker/logs-nginx:/var/log/nginx:ro
      - crowdsec-db:/var/lib/crowdsec/data/
      - /var/log/auth.log:/var/log/auth.log:ro
      - /var/log/syslog:/var/log/syslog.log:ro

After a first start, I issued
cscli lapi register --machine WHATEVER --url http://10.10.10.10:8080

and on the LAPI:
cscli machines validate WHATEVER

Afterwards, /etc/crowdsec/local_api_credentials.yaml was pointing to the correct LAPI and the LAPI showed the new machine being online.

After a docker compose down && docker compose up -d, local_api_credentials.yaml was re-created from scratch with default values.

Well... This way, no multi-server setup is possible.

Please change this behaviour so that local_api_credentials.yaml will be preserved.

What did you expect to happen?

Preserve local_api_credentials.yaml

How can we reproduce it (as minimally and precisely as possible)?

see above

Anything else we need to know?

No response

Crowdsec version

docker crowdsecurity/crowdsec:latest

OS version

No response

Enabled collections and parsers

No response

Acquisition config

No response

Config show

No response

Prometheus metrics

No response

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

No response

@Kornelius777 Kornelius777 added the kind/bug Something isn't working label Jan 31, 2025
Copy link

@Kornelius777: Thanks for opening an issue, it is currently awaiting triage.

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@Kornelius777
Copy link
Author

answering myself:

My bad!

After amending my docker-compose.yml to

  crowdsec:
    image: crowdsecurity/crowdsec
    hostname: crowdsec
    container_name: crowdsec
    environment: 
      COLLECTIONS: "crowdsecurity/nginx"
      DISABLE_LOCAL_API: true
      AGENT_USERNAME: "WHATEVER"
      AGENT_PASSWORD: "WHATEVER"
      LOCAL_API_URL: "http://10.10.10.10:8080"
    depends_on:
      - nginx
    volumes:
      - /docker/crowdsec:/etc/crowdsec
      - /docker/logs-nginx:/var/log/nginx:ro
      - crowdsec-db:/var/lib/crowdsec/data/
      - /var/log/auth.log:/var/log/auth.log:ro
      - /var/log/syslog:/var/log/syslog.log:ro

everything works as expected.

Please close!

@LaurenceJJones
Copy link
Contributor

You beat me to it, yes when using an external LAPI you must define these 2 environments at least:

      DISABLE_LOCAL_API: true
      LOCAL_API_URL: "http://10.10.10.10:8080"

The others are not needed directly needed unless you are using secrets or something but you can hardcode it if you want to ensure they never change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working needs/triage
Projects
None yet
Development

No branches or pull requests

2 participants