简体   繁体   中英

Docker run not recognizing --rm

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

The syntax for the command is

$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

So it should be

docker run ... --rm ... dockeragent:latest SOMESTUFF 

All flags should come before the container name:

$ docker run --rm -e SOMESTUFF dockeragent:latest ...

everything that comes after the image name is passed as an argument to the entrypoint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM