15

I want to run a set of commands in a docker container, e.g.:

docker run -i <image> cmd1 | cmd2

Both cmd1 and cmd2 should be run inside the container.

Is it possible? If not, what are the alternatives?

gc5
  • 9,468
  • 24
  • 90
  • 151
  • "I would like to have my pipe not saved on the docker container since I'm only saving the inline command in an external bash script." - It's really not clear what this means. From context, my best guess is that you're asking how to ensure that both `cmd1` and `cmd2` are executed *inside* the container - is that correct? – Oliver Charlesworth Nov 26 '17 at 18:46
  • @OliverCharlesworth yes, I'll update the question accordingly, thanks – gc5 Nov 26 '17 at 19:08
  • 2
    See https://stackoverflow.com/questions/28490874/docker-run-image-multiple-commands – Oliver Charlesworth Nov 26 '17 at 19:19
  • @OliverCharlesworth it works, but environment variables are missing. If you want you can put it as an answer (if you also know how to solve for env variables, better). – gc5 Nov 26 '17 at 19:28
  • 1
    Which environment variables? AFAIK this question is a duplicate of the linked question, so normally I'd vote to close as such. – Oliver Charlesworth Nov 26 '17 at 19:29
  • 1
    @OliverCharlesworth you are right, let's close it. – gc5 Nov 26 '17 at 19:30

0 Answers0