-1

I have some container running for a while. so the bash history is already filled in with other commands. So how can I now extract the initial command I used to start container with all its parameters?

Roman
  • 13
  • 5
  • Have you tried `docker container inspect `? Inside that json you can find the `CMD` you used. – tgogos May 08 '18 at 11:43
  • hi. nope. it is not helping. it is only shown params i have passed inside the contaone. but it does not show params i have passed to the docker itself. e.g. what folders\ports i have forwarded... – Roman May 08 '18 at 12:29

2 Answers2

0

So how can I now extract the initial command I used to start container with all its parameters?

  • Since your current history is overwritten and you can't extract original calling line from there you have to recreate it. Best effort you can do is:

    docker inspect <container>
    

    Regardless if your container is stopped or started, there you have all necessary information about container (entry point, command, ports, environment variables...) that can help you regenerate exact arguments to run.

Const
  • 5,597
  • 3
  • 18
  • 25
-1

From what I understand, you want to recall how did you run the compose file / docker command, right?

You can do it in many ways (on Linux/Mac):

$ history | grep docker

And inspect a output of this command to find the command you used.

Another way is to press ctrl+r in your terminal, type docker and continue to press the combination (after you've typed docker) until you spot the command that you are interested in.

Developer Guy
  • 2,198
  • 6
  • 18
  • 34
trust512
  • 1,723
  • 1
  • 16
  • 14
  • This tool may help you to construct the docker run command https://github.com/nexdrew/rekcod – Rajiv May 08 '18 at 12:24
  • this might help, but the history depth is limited by default with env variable $HISTSIZE. initial command was cleared out with newer ones. – Roman May 08 '18 at 12:33
  • Then try to recall if there is anything that makes the command unique, like a port number, volume, container name, and then change `docker` with the unique identifier – trust512 May 08 '18 at 12:51