I am trying to set up a docker container that automatically deletes itself when done. I see there is a command to do this built into docker with the –rm flag.
I have my image and can build a container and run a job from an azure agent in it. The only thing left to do is to have it clean up after itself.
Here is the command I use to run it:
docker run -e SOMESTUFF dockeragent:latest --once --rm
And this is the error I get:
docker : Unrecognized command-line input arguments: 'rm'. For usage refer to: .config.cmd --help or ./config.sh --help
At line:1 char:1
Why can it not recognize the input rm?
https://docs.docker.com/engine/reference/run/#clean-up—rm
2
Answers
The syntax for the command is
So it should be
All flags should come before the container name:
everything that comes after the image name is passed as an argument to the entrypoint