Docker run: multi-line

Viewed 9355

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.

3 Answers

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.

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.

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.

Related