Accessories are not named distinctly per destination
I'm using Kamal to deploy a Rails app with a postgres database and I'm trying to set up a staging environment on the same server as production. My web containers get complex names, but include "APP-web-staging", where "APP" is the service name from deploy.yml and "staging" is the destination name I've given to Kamal. This is nice for co-location multiple deployments of the same app on a machine.
However, I'm running into problems with postgres, because the database accessory container is just called "APP-postgres", with no destination name included. When I try to setup my staging environment, I get an error like:
docker: Error response from daemon: Conflict. The container name "/APP-postgres" is already in use by container "a67...81b". You have to remove (or rename) that container to be able to reuse that name.
A workaround for this is to change my service name for the staging destination to "APP_staging", but then I'll end up with web container called "APP_staging-staging", which is a little silly. What is the recommended practice for using Kamal-managed accessories in a multiple-deployment-per-machine scenario?
Yes that is a problem, but probably not fixable without breaking existing deployments.
Does something like this work as a workaround?
accessories:
postgres:
service: postgres-<%= ENV["KAMAL_DESTINATION"] %>
Thanks for the idea, Donal. I can't easily test that workaround at the moment. Running with the main service key set to [app_name]_[env_name] is working fine for me at the moment, and having a standard prefix for all of the containers is helpful at times.