How can I run containers detached and have them automatically removed when they exit?

docker

Solution

These options no longer conflict as of Docker version 1.13.0

There was a pull request that moves the `--rm` option daemon-side and allows for running containers detached with the removal option: https://github.com/docker/docker/pull/20848

Problem

Why are `-d` and `--rm` conflicting arguments in Docker? ``` $ docker run -d --rm image Conflicting options: --rm and -d ``` I have a number of containers that run unit/functional/integration tests. The Docker containers start, run the tests, and then stop. I run them detached since I only care about the results, but I'd also like the containers to be removed after the container exits. What would be a good way to do this?

Original source