Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi line docker run command on windows

I want to run multi line docker run command on windows.

say,

docker run --name packer \
-d ekambaram/packer:1.4.0

getting the below error

C:\Users\ekambaram_pasham>docker run --name packer \
docker: invalid reference format.
See 'docker run --help'.

C:\Users\ekambaram_pasham>-d ekambaram/packer:1.4.0
'-d' is not recognized as an internal or external command,
operable program or batch file.
like image 397
P Ekambaram Avatar asked Apr 25 '19 10:04

P Ekambaram


People also ask

How to run multi line Docker Run command in PowerShell?

To run multi line docker run command in PowerShell, use backtick (`) character at the end of each line in Dockerfile. I hope you found above article on Powershell multiline command with comments useful and educational.

How do I use Docker for Windows?

When using Docker for Windows, also known as Docker Desktop, a Docker daemon is installed within a Windows Subsystem for Linux (WSL) 2 VM. Commands that are run from the Docker CLI on a Windows command prompt are passed through to the Docker daemon:

How do I run a shell script in Docker?

You can use different approaches (e.g., set -eux; some command; some other command; ). By default (in a Linux Dockerfile), RUN <shell commands> is equivalent to sh -c '<shell commands>, and docker build will execute that step, and commit the results once the sh -c terminates successfully.

How do I break up a dockerfile into multiple lines?

Using a backslash is the standard way to break up long lines into multiple lines on Unix-like operating systems. Since most Docker images are built using some form of Linux base image, then the backslash strategy works here as well. Docker also allows for it in other Dockerfile instructions (such as LABEL ).


Video Answer


1 Answers

In the command prompt on windows I was able to run multi line docker run commands as shown below

docker run --name packer ^
-d ekambaram/packer:1.4.0

use ^ as command separator instead of \

C:\Users\ekambaram_pasham>docker run --name packer ^
More? -d ekambaram/packer:1.4.0
7e3599a599a7b19613f50323456d66a324c2ac558bb71eb9060bda54dfcd8f4d

For PowerShell, you will need to substitute with ` (back tick) instead of ^ or \ as below

docker run -p 80:80 -p 443:443 `
           -h hostname.domain `
           -e "MYSQL_ROOT_PASSWORD=password" `
           -e "SOGO_WORKERS=1" `
           -e "POSTMASTER_PASSWORD=(plain)password" `
           -e "IREDAPD_PLUGINS=['reject_null_sender', 'reject_sender_login_mismatch', 'greylisting', 'throttle', 'amavisd_wblist', 'sql_alias_access_policy']" `
           -v iredmail_mysql:/var/lib/mysql `
           -v iredmail_vmail:/var/vmail `
           -v iredmail_clamav:/var/lib/clamav `
           --name=iredmail lejmr/iredmail:mysql-latest
like image 130
P Ekambaram Avatar answered Oct 20 '22 03:10

P Ekambaram