0

Is it possible to run a multi-line command from Dos on Windows, trying to not create a Dockerfile for this sample.

docker run --rm -it -v "$GOPATH":/go -w /go/src/github.com/iron-io/ironcli golang:1.4.2-cross sh -c '
for GOOS in darwin linux windows; do
  for GOARCH in 386 amd64; do
    echo "Building $GOOS-$GOARCH"
    export GOOS=$GOOS
    export GOARCH=$GOARCH
    go build -o bin/ironcli-$GOOS-$GOARCH
  done
done
'

I see lots of people using this cross compiler for Go Language

Motakjuq
  • 1,669
  • 1
  • 6
  • 21
user3888307
  • 1,795
  • 2
  • 13
  • 27
  • 1
    This has more to do with how arguments are parsed on the command line than docker or go. Apparently the [`^` character can be used to escape newlines](https://stackoverflow.com/questions/605686/windows-how-to-specify-multiline-command-on-command-prompt). You can also reformat that shell script to fit on a single line by using `;` in place of newlines except after the `do` keyword. – nothingmuch Dec 15 '16 at 02:52
  • Do you think this is the simplest way to type the command? Or you just want to know how to multiline command on `cmd` propmpt? – Rao Dec 15 '16 at 02:55
  • 1
    If this is something you'll be using often, why not create a new image from the one you're using, copy your command into a script file and copy the script file into the image? I.e. FROM golang:1.4.2-cross COPY buildscript.sh ENTRYPOINT ['buildscript.sh'] – jste89 Dec 15 '16 at 13:46
  • I ended up install Cygwin and using the bash shell to get this to work. Thank you for the suggestion of just putting the shell script on the Image, I was also looking at going that route. – user3888307 Dec 16 '16 at 06:07
  • [How to write commands with multiple lines in Dockerfile while preserving the new lines?](https://stackoverflow.com/q/33439230/6521116) – LF00 Nov 24 '17 at 06:16

0 Answers0