"docker: Conflicting options: --restart and --rm"
I get this error when I try to SSH into one of my application containers if its options include restart: unless-stopped.
Reproduction steps:
- Update a
serverconfiguration indeploy.ymlto have the following option:
options:
restart: unless-stopped
- Run
kamal app exec bash -i(or any otherexeccommand for that matter) - Get the following error:
kamal app exec bash -i
Get most recent version available as an image...
Launching interactive command with version latest via SSH from new container on 192.168.1.5...
docker: Conflicting options: --restart and --rm.
See 'docker run --help'.
Kamal runs the command using docker run --rm while also including all the options from deploy.yml, which works unless one of your options is the one mentioned above.
I'm not saying this is a bug in Kamal, but I would like to hear if anyone has any ideas about fixing or getting around this issue :)
I also just ran into this. A workaround is to pass the --reuse flag which will run the command in an existing container. This works:
kamal app exec bash -i --reuse
Agree it would be better to just remove the --restart argument somewhere here though.
Does that seem like a reasonable option?
@artemgordinskiy - setting the restart policy to unless-stopped is redundant, because Kamal will do that anyway, so you could remove the option from your config.
With a custom restart option, Kamal just tags it on the end, so we have docker run foo ... --restart-policy unless-stopped --restart-policy <policy-from-options> .... Docker just seems to pick the last one so we get the desired behaviour by chance.
@czue's your suggestion makes sense for the bug reported here
So we should:
- Replace
unless-stoppedwith the user supplied restart policy rather than append it - Remove the policy for
app execcommands - Disallow a policy of
always- this would have undesired behaviour of restarting previously deployed versions after a docker restart.