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 <org> -output /root/output.txt -thogEntropy -token <githubtoken>

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.


Docker container dies when there is no process run in it. If you want a docker not to die you need a process to keep runing, This can be any process even bash process (/bin/bash).

Usually a docker container can be re-started with docker start command, but you are using the --rm flag which tell the docker deamon to delete the container once it killed, meaning that when the container is stoped auto delete it, therefor you cannot re-start the container.

Your problem is that you are using the docker in a wrong way, you tell the docker container to write the output of the process to the docker container file system and then delete the container, then you try to copy it.

You should use a mounted volume from your host (by using -v flag) and write the output there, or you can enter docker with runing the command /bin/bash at the end, then you can run the process manually from inside the docker container, wait for it to finished, press ctrl+p+q to exit the container without killing it and copy the file using docker cp command and then kill the container what ever make you. Note that because /bin/bash the container has a process and therefor it will not be killed (as your question was "how to stop from container from dying...").


I don't know about git-all-secret specifically, but from what I understand you are trying to capture the output produced by that tool. Since docker maps by default the standard output of a container to the standard output of the client docker command, you may achieve the desired result using something like that (untested):

sudo docker run --rm -it abhartiya/tools_gitallsecrets -org $org \
     -output /dev/stdout \
     -thogEntropy -token $githubtoken \
 > ./output.txt

Many tools allow - as a synonym for /dev/stdout, so this might work:

sudo docker run --rm -it abhartiya/tools_gitallsecrets -org $org \
     -output - \
     -thogEntropy -token $githubtoken \
 > ./output.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.