Adam
Adam

Reputation: 5445

Why does docker say that -d and --rm are conflicting options for running a container?

A minor issue but I want to run docker containers in dev with docker run --rm so that I don't have to remove them after I stop them, especially since I'm changing the command line parameters with virtually every run.

However my containers pump out lots of logging onto stdout if I don't use docker run -d.

Then I can't use --rm anymore, because docker complains:

[adam@gondor ~]$ docker run --rm -d -p 10040:443 --name rproxy adam-rproxy
Conflicting options: --rm and -d

Admittedly I could just run stop and rm together on the command line:

docker stop rproxy; docker rm rproxy

but I know I'll forget, get annoyed and start worrying I'm moving out on the autistic spectrum!

docker run options

Upvotes: 3

Views: 2224

Answers (2)

BMitch
BMitch

Reputation: 263906

Docker added the ability to have --rm and -d when they moved the --rm to a server side action in 1.13.0. This was covered in PR 20848. Before this release, the delete was handled on the docker client, and with detached mode, the client was not monitoring the container to detect the exit.

You'll need to upgrade to at least this version on both your client and server for this feature to work. I'd recommend upgrading to 17.09 since it's the current stable CE release.

Upvotes: 3

Birchlabs
Birchlabs

Reputation: 8056

I cannot reproduce this.

The following detaches fine and can be stopped just fine (resulting in removal, as required) in Docker version 17.09.0-ce, build afdb6d4:

docker run --rm -d --name yes alpine:3.7 yes

I also tried adding some ports to closer match your example, but that was no problem either.

Upvotes: 0

Related Questions