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.
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.
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:
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.
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 ).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With