basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.37k stars 357 forks source link

kamal setup crashing on redis accessory #488

Open lizdeika opened 9 months ago

lizdeika commented 9 months ago

Hi, I have an issue with kamal setup crashing on redis accessory.

  INFO [4243044c] Running docker run --name app-redis --detach --restart unless-stopped --log-opt max-size="10m" --publish 36379:6379 --env-file .kamal/env/accessories/app-redis.env --volume /var/lib/redis:/data --label service="app-redis" redis:latest redis-server --save 60 1 on 10.0.0.6
Releasing the deploy lock...
  Finished all in 9.0 seconds
  ERROR (SSHKit::Command::Failed): Exception while executing on host 10.0.0.6: docker exit status: 125
docker stdout: Nothing written
docker stderr: docker: Error response from daemon: Conflict. The container name "/app-redis" is already in use by container "069c97eb7287142e2fbaaad7de82c656a488fdb7bc115dcebbaadbfe799f5f8f". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

redis deploy config:

accessories:
  redis:
    image: redis:latest
    cmd: redis-server --save 60 1
    hosts:
      - 10.0.0.6
    port: "36379:6379"
    volumes:
      - /var/lib/redis:/data

I have tried kamal remove and rebuilding/reinstalling the hosting instance from ground up to no avail. The only thing that helps is sshing to the instance and doing docker rm -f /app-redis. Then I am able to run kamal setup for one time, second run crashes again.

picolino commented 9 months ago

Some time ago I've stuck with the same issue, but with mongodb database.

As I understand the problem - kamal setup is a command only for first-time deployment. For next deployments you should use kamal deploy command instead.

shaneshort commented 9 months ago

@picolino I agree, but it's possible you could have an issue deploying, I some guard rails would be nice here, "oh the container exists, don't start another one" etc.

hapiben commented 7 months ago

@lizdeika Any luck solving the issue?

lizdeika commented 7 months ago

@hapiben no, sadly no luck the only workaround is executing docker rm -f /app-redis on the redis server machine

BranLiang commented 6 months ago

I also had similar issue, and I commented the accessory part after the first setup, just so I could run kamal setup again after the first setup.