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,579
  • 10
  • 50
  • 58
Chris Stryczynski
  • 25,295
  • 38
  • 135
  • 245

2 Answers2

2

docker start is the command I was looking for.

docker start -ia duplo

Chris Stryczynski
  • 25,295
  • 38
  • 135
  • 245
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
  • 27,609
  • 6
  • 52
  • 56