Skip to content

Cleanup containers from failed accessory deployments #1545

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

Open
adenta opened this issue May 8, 2025 · 0 comments
Open

Cleanup containers from failed accessory deployments #1545

adenta opened this issue May 8, 2025 · 0 comments

Comments

@adenta
Copy link

adenta commented May 8, 2025

my deploy.yml looks something like this:

# Name of your application. Used to uniquely configure containers.
service: name

# Name of the container image.
image: user/name

# Deploy to these servers.
servers:
  web:
    -  123.4.5.6 # Replace with your actual server IP

# Enable SSL auto certification via Let's Encrypt
proxy:
  ssl: true
  hosts:
    - example.com
    - www.example.com

# Credentials for your image host.
registry:
  password:
    - KAMAL_REGISTRY_PASSWORD

# Inject ENV variables into containers
env:
  clear:
    NODE_ENV: production

# Configure the image builder.
builder:
  arch: amd64

# Aliases for common operations
aliases:
  logs: app logs -f
  remove_container: server exec docker rm -f
  nginx: app exec --interactive --reuse "nginx -s reload"

accessories:
  formbricks:
    proxy:
      ssl: true
      host: forms.sqlhorse.com
      app_port: 3001
      forward_headers: true
      healthcheck:
        path: /
        interval: 5
        timeout: 3
    image: ghcr.io/formbricks/formbricks:latest
    host: 123.4.5.6
    port: "127.0.0.1:3001:3001"
    env:
      secret:
        - WEBAPP_URL
        - NEXTAUTH_URL
        - DATABASE_URL
        - NEXTAUTH_SECRET
        - ENCRYPTION_KEY
        - CRON_SECRET
    directories:
      - formbricks_data:/home/nextjs/apps/web/uploads

I'm trying to package formbricks as a kamal accessory. I botched the boot (I had misconfigured the port mapping), and am now stuck in some sort of death loop:

 sql-horse-marketing git:(main) ✗ kamal accessory details formbricks                         
  INFO [5dff925e] Running docker ps --filter label=service=sql_horse_marketing-formbricks on 123.4.5.6
  INFO [5dff925e] Finished in 1.303 seconds with exit status 0 (successful).
Accessory formbricks Host: 123.4.5.6
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

➜  sql-horse-marketing git:(main) ✗ git push origin pricing-v2        
➜  sql-horse-marketing git:(main) ✗ kamal accessory boot formbricks
  INFO [f2715887] Running /usr/bin/env mkdir -p .kamal on 123.4.5.6
  INFO [f2715887] Finished in 0.818 seconds with exit status 0 (successful).
Acquiring the deploy lock...
  INFO [177a10b5] Running docker login ghcr.io -u [REDACTED] -p [REDACTED] on 123.4.5.6
  INFO [177a10b5] Finished in 0.205 seconds with exit status 0 (successful).
  INFO [acbaa43f] Running docker network create kamal on 123.4.5.6
  INFO [c144171b] Running /usr/bin/env mkdir -p $PWD/sql_horse_marketing-formbricks/formbricks_data on 123.4.5.6
  INFO [c144171b] Finished in 0.160 seconds with exit status 0 (successful).
  INFO [fe88926e] Running /usr/bin/env mkdir -p .kamal/apps/sql_horse_marketing/env/accessories on 123.4.5.6
  INFO [fe88926e] Finished in 0.164 seconds with exit status 0 (successful).
  INFO Uploading .kamal/apps/sql_horse_marketing/env/accessories/formbricks.env 100.0%
  INFO [e4f4a359] Running docker run --name sql_horse_marketing-formbricks --detach --restart unless-stopped --network kamal --log-opt max-size="10m" --publish 127.0.0.1:3001:3001 --env-file .kamal/apps/sql_horse_marketing/env/accessories/formbricks.env --volume $PWD/sql_horse_marketing-formbricks/formbricks_data:/home/nextjs/apps/web/uploads --label service="sql_horse_marketing-formbricks" ghcr.io/formbricks/formbricks:latest on 123.4.5.6
Releasing the deploy lock...
  ERROR (SSHKit::Command::Failed): Exception while executing on host 123.4.5.6: docker exit status: 125
docker stdout: Nothing written
docker stderr: docker: Error response from daemon: Conflict. The container name "/sql_horse_marketing-formbricks" is already in use by container "2d7101a6b6cc70d37c561e673c22e13da1d781a25cbcffee5cfa80a9ab86a358". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

➜  sql-horse-marketing git:(main) ✗ kamal accessory

The accessory wont boot, AND it's not running. If the container doesn't pass the healthcheck, then the container ends up in a vestigial state of conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant