0

For example once I create a container with name of "duplo":

docker run --name="duplo" -it /bin/bash -c "sudo /build/backup.sh".

How do I execute an additional command within the container after it exits? I can see it listed by docker ps -a.

Henrik Aasted Sørensen
  • 6,966
  • 11
  • 51
  • 60
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286

2 Answers2

4

docker start is the command I was looking for.

docker start -ia duplo

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1

As long as it is stopped, you can do nothing.

Maybe you can start it

https://docs.docker.com/engine/reference/commandline/start/

see the doc

and if it says running, you can connect and launch some commands using

docker exec -it duplo bash

or maybe just modify a string in a file

docker exec -it duplo sed...

, see the associated doc

https://docs.docker.com/engine/reference/commandline/exec/

user2915097
  • 30,758
  • 6
  • 57
  • 59