How to stop a container dying at the end of an execution? I'm running git-all-secrets over our organisation to ensure we have nothing exposed. I'm doing this using:

sudo docker run --rm -it abhartiya/tools_gitallsecrets -org &lt;org&gt; -output /root/output.txt -thogEntropy -token &lt;githubtoken&gt;


I've monitored the events for this repository, and after the command completes, the following events fire:

2019-02-21T13:01:36.386539368Z container die cc479e7ac878f39c1e555eea1cbc9105dc06e21a526639975cd15f031297ab23 (exitCode=0, image=abhartiya/tools_gitallsecrets, name=inspiring_bell)
2019-02-21T13:01:36.602243215Z network disconnect 26b5a225be28b13153e587c4d1464361957ac899bc1a4152c6ae5aacc3229a0f (container=cc479e7ac878f39c1e555eea1cbc9105dc06e21a526639975cd15f031297ab23, name=bridge, type=bridge)
2019-02-21T13:01:37.235130059Z container destroy cc479e7ac878f39c1e555eea1cbc9105dc06e21a526639975cd15f031297ab23 (image=abhartiya/tools_gitallsecrets, name=inspiring_bell)


Since the container is  then destroyed, I can't then copy the file locally after exection by using:

a@ubuntu-s-2v-2-01:~$ sudo docker cp cc479e7ac878:/root/output.txt ./output.txt                                                                                                                     │ 0 -rw-r--r-- 1 codingo codingo     0 Dec 19 04:49 .sudo_as_admin_successful
Error: No such container:path: cc479e7ac878:/root/output.txt                         


I'm still new to docker, so I'm not sure what the solution to my problem is - but how can I have  the docker contain
Option --rm tells Docker explicitly to remove the container after the (main) command finished. Just leave it out.

Note that none of the examples contain this option; they only use it for -help.

As an alternative (which lets you keep --rm), you can tell Docker to mount a volume at /root. Volumes persist after the containers mounting them go away, so you can access the data written there. However, for your purposes here, a simple bind mount is quite enough; add

-v .:/root


to have it write the output file to the current (host) directory. You may have to adjust this if /root is used heavily; you probably want to use a previously empty directory on both sides.