0

I am not asking this question: See full command of running/stopped container in Docker

What I am asking is, if someone runs a docker container from the host with a command such as:

docker run --lots --of --mysterious --parameters --volumes --etc image-name

Is there some way for someone else to obtain the original command line in the host system that was used to create the container?

My guess is that no, that you would have to reconstruct it manually by putting together all information obtained from docker inspect... but I may be wrong.

Edit

It seems there is no way to get this information from docker itself, but as explained in the comments below, you can always type history | grep "docker run" and search for the one that launched the container.

Luis Crespo
  • 670
  • 6
  • 19
  • 1
    The Linux history command gives info on the last executed command so if you are using a common user to execute that command should be visible in history or in the .bash_history profile – error404 Mar 07 '19 at 09:24
  • you might be able to see the full command in `ps -ef | grep 'docker'` – scipsycho Mar 07 '19 at 09:31
  • 1
    @yashbagarka I did not think about this cool workaround. I typed `history | grep "docker run"` and there it was :-). Thank you! – Luis Crespo Mar 07 '19 at 10:17
  • @scipsycho I tried the `ps -ef | grep "docker"` and found that the `docker` command-line tool launches other processes and then dies. So what I see in the ps output is not the original docker command, but something else with very different parameters. – Luis Crespo Mar 07 '19 at 10:20
  • @LuisCrespo update the question with answer. Pls accept it – error404 Mar 07 '19 at 10:46

1 Answers1

1

Marking the answer.

linux history would be the best way to get the docker command you had executed earlier.

error404
  • 2,313
  • 2
  • 10
  • 19