-1

How can i get the full docker run commandline within the container?

I need this for protocols.

eg

docker run -d -e foo=bar -v $PWD:/app image

docker exec -it container bash
# get commandline ??

many thanks

4
  • What do you mean by command line? can you explain a bit Commented Nov 6, 2020 at 10:17
  • its not really difficult to understand - i need the commandline "docker run -d -e foo=bar -v $PWD:/app image" WITHIN the container Commented Nov 6, 2020 at 10:28
  • Okay I got it.. you want to run "docker run " command inside running container, right? Commented Nov 6, 2020 at 10:45
  • Why do you need this; what would you do with this information if you had it? Commented Nov 6, 2020 at 12:12

1 Answer 1

0

docker itself does not offer a straight-forward way to get the actual command which started a container. But you can docker inspect the container and reconstruct the command which started it from that.

There are some tools trying to automate this such as runlike, rekcod or this template for docker inspect, see How to show the run command of a docker container for more in this.

If you want to get this information inside a running container you'll have to mount the docker socket into it to be able to use these tools inside the container, see Access Docker socket within container.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.