cli
cli copied to clipboard
cli/config/configfile(autoRemove): New config.json option.
Allow user to set "autoRemove": true
in their ~/.docker/config.json
to have --rm=true
be set by default for docker run -it <containter> -- sh
commands.
- What I did
I surfaced an option in the ~/.docker/config.json
to always have --rm=true
when running containers, so that my container list doesn't get cluttered. It's called "autoRemove": true
to match the code, but that's perhaps not the best name.
Fixes #4763.
- How I did it
I added a field in the ConfigFile struct, and used it in the container run
command.
- How to verify it
I ran the binary with and without "autoRemove": true
in the config.json
file, and observed that the flag was set correctly, both with "printf debugging" and observing my stopped containers list.
- Description for the changelog
- Added
autoRemove
boolean option toconfig.json
, so that--rm
is implicit with runningdocker run ...
.
- A picture of a cute animal
(Canada Goose from https://commons.wikimedia.org/wiki/File:Canada_goose_gosling_-_natures_pics.jpg)
Thanks for the thoughtful responses so far!
I think this needs a wider discussion, and I'd rather not add an "ad-hoc" field to this config. More so because this would currently work for
docker run
, but won't set it fordocker create
, nor (e.g.)docker compose run
.I know that "defaults" have been discussed in the past, but we need to think over the implications, which options we want to allow having a default, but also make sure that these defaults are discoverable, otherwise behavior will be confusing (different behavior depending on this config, which can be a huge head-ache trying to find "what happened" when debugging).
Yes, completely understand and agree. I am keen for this option though – what would be (my?) next steps to help drive something like this along? I'm happy to provide strawman PRs and so on.