Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jimbo8098/dc1f8da7e9ecf562f9bfd167b264c64f to your computer and use it in GitHub Desktop.
Save jimbo8098/dc1f8da7e9ecf562f9bfd167b264c64f to your computer and use it in GitHub Desktop.

In the current Windows 2019 meta (build 1809), it is not possible to use && to run commands sequentially in the one process. The same syntax is true in build 2004 of Windows 10 Pro. You need to use this format at the moment:

RUN echo "command 1"; if ($?) {\
    echo "command 2"; if ($?) {\
    echo "command 3"; }}

The backslashes are to escape the newline character for Docker.

There is a PR open for comment at PowerShell/PowerShell#9849 which refers to changing this so that && works but in this particular LTSC build of Windows, you can't use it. At this time it looks to be merged so presumably we will see it soon enough.

This was quite difficult to find for me so I'll add it here in case it confuses anyone else <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment