I have a docker container based on an image that, by default, does not run any command when started. I need to execute a command in that container.
Running docker run -it [container tag] runs, but there are two problems:
- It runs in interactive mode (as one would expect), while I need something that can run on a server, without human supervision.
- I need to perform a
docker cpcommands before executing the command I need to run.
Basically, what I have is:
docker createcreates the container.docker cpmoves over the files I need.docker startstarts the container, but since it has no default command to run, it exits immediately.docker execrefuses to run my command, because the container is stopped. No amount ofdocker startcan fix this.
I cannot edit the image Dockerfile, so unfortunately, adding a while true; done (suggested here) as default command to run isn't possible.
I assumed a command that would chain start and exec back-to-back (and ensure the container doesn't close before the command is run, similar to how run is create-start-attach) would be already existing, but I can't seem to find anything neither in the documentation nor in other forum answers.