3

Is there a way of running in windows command prompt, a "docker run" command over multiple lines e.g. instead of

"docker run -v .. --name .. --entrypoint .. <image_name>"

something like

"docker run 
-v. ..
--name ..
--entrypoint ..
<image_name>"

It's becoming a pain to edit! Thanks, Jonny

edit: I've tried adding in ^ command, it doesn't work. Just errors with "docker run" requires at least 1 argument.

Jonny Phelps
  • 2,687
  • 1
  • 11
  • 20
  • Possible duplicate of [Windows: How to specify multiline command on command prompt?](https://stackoverflow.com/questions/605686/windows-how-to-specify-multiline-command-on-command-prompt) – n00dle Sep 21 '18 at 09:32
  • Possible duplicate of [Long commands split over multiple lines in Windows Vista batch (.bat) file](https://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-windows-vista-batch-bat-file) – Henry Sep 21 '18 at 09:33
  • edited the question, I didn't have much luck with adding ^ in – Jonny Phelps Sep 21 '18 at 10:11

3 Answers3

3

I think the best tool is docker-compose and it uses docker-compose.yml file to prepare run or build instructions.

So it will be a text file in yml or yaml format and take a reference on different keywords for it's prepartion.

https://docs.docker.com/compose/overview/

Compose is a tool for defining and running multi-container Docker applications.  
With Compose, you use a YAML file to configure your application’s services.   
Then, with a single command, you create and start all the services from your configuration.   
To learn more about all the features of Compose, see the list of features.
fly2matrix
  • 2,351
  • 12
  • 13
2

In case anyone ended up here instead of the possible duplicates above and is put off by the ^ didn't work for me: if using dos (i.e. not powershell) replacing the characters \ space and backslash at the end of the docker command for linux with ^ i.e. space and caret at the end of all but the penultimate line, seems to work for me.

fawr
  • 21
  • 1
0

docker run -v ^ more? --name ^ more? --entrypoint ^ more? <image_name>

more? is by default asking for further commands in Command Prompt.

In windows, you can use ^ caret sign and \ backslash on mac to run multiple line of commands for docker.