kamal icon indicating copy to clipboard operation
kamal copied to clipboard

"volumes" options broken, because of the default cords volume?

Open ledowong opened this issue 1 year ago • 2 comments

Kamal 1.0

volumes doesn't work in app, but it works in accessories, config below:

servers:
  web:
    hosts:
      - 192.168.1.10
    options:
      add-host: host.docker.internal:host-gateway
    volumes:
      - "/nas:/nas"
accessories:
  db:
    image: postgres:14
    host: 192.168.1.10
    port: 5432
    env:
      clear:
        POSTGRES_HOST_AUTH_METHOD: trust
    volumes:
      - "/psql/14/main:/var/lib/postgresql/data"

The docker command shows in console when kamal deploy is running, are missing --volume for nas, just cords:

docker run --detach --restart unless-stopped --name uk-web-xxx --hostname 192.168.1.10-xxx -e KAMAL_CONTAINER_NAME="uk-web-xxx" --env-file .kamal/env/roles/uk-web.env --health-cmd "(curl -f http://localhost:3000/up || exit 1) && (stat /tmp/kamal-cord/cord > /dev/null || exit 1)" --health-interval "1s" --volume $(pwd)/.kamal/cords/uk-web-xxx:/tmp/kamal-cord --log-opt max-size="10m" --label service="uk" --label role="web" --label traefik.http.services.uk-web.loadbalancer.server.scheme="http" --label traefik.http.routers.uk-web.rule="Host(\`uk.example.com\`)" --label traefik.http.middlewares.uk-web-retry.retry.attempts="5" --label traefik.http.middlewares.uk-web-retry.retry.initialinterval="500ms" --label traefik.http.routers.uk-web.middlewares="uk-web-retry@docker" --add-host "host.docker.internal:host-gateway" ghcr.io/username/uk:xxx

If I cheat and set the deploy.yml like this, then everything works:

servers:
  web:
    hosts:
      - 192.168.1.10
    options:
      add-host: host.docker.internal:host-gateway
      volume: "/nas:/nas"

docker command become:

docker run --detach --restart unless-stopped --name uk-web-xxx --hostname 192.168.1.10-xxx -e KAMAL_CONTAINER_NAME="uk-web-xxx" --env-file .kamal/env/roles/uk-web.env --health-cmd "(curl -f http://localhost:3000/up || exit 1) && (stat /tmp/kamal-cord/cord > /dev/null || exit 1)" --health-interval "1s" --volume $(pwd)/.kamal/cords/uk-web-xxx:/tmp/kamal-cord --log-opt max-size="10m" --label service="uk" --label role="web" --label traefik.http.services.uk-web.loadbalancer.server.scheme="http" --label traefik.http.middlewares.uk-web-retry.retry.attempts="5" --label traefik.http.middlewares.uk-web-retry.retry.initialinterval="500ms" --label traefik.http.routers.uk-web.middlewares="uk-web-retry@docker" --add-host "host.docker.internal:host-gateway" --volume "/nas_video:/nas_video" ghcr.io/username/uk:xxx

ref: https://discord.com/channels/1084848369073131531/1084848372667654248/1162141858038820945

ledowong avatar Oct 12 '23 22:10 ledowong

Same problem here. Accessories is running fine but app does not. I tried volumes and directories with absolute names. For volumes I created the folder and chmod'ed it to 777. System is Linux xxx.yyy.zzz 5.4.0-62-generic #70-Ubuntu SMP Tue Jan 12 12:45:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

gunnarmagholder avatar Nov 24 '23 13:11 gunnarmagholder

I haven't verified whether this was changed since then but the volume option should be specified differently. See https://kamal-deploy.org/docs/configuration/traefik/#traefik-container-configuration for more info.

99linesofcode avatar May 16 '24 19:05 99linesofcode