# Runing bash in a Windows container

**URL:** <https://forums.docker.com/t/runing-bash-in-a-windows-container/85254>\
**Category:** Docker Desktop\
**Created:** [December 3, 2019, 4:22pm UTC](https://forums.docker.com/t/runing-bash-in-a-windows-container/85254 "2019-12-03T16:22:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![albertsen](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@albertsen](https://forums.docker.com/u/albertsen)\
**Post date:** [December 3, 2019, 4:22pm UTC](https://forums.docker.com/t/runing-bash-in-a-windows-container/85254/1 "2019-12-03T16:22:13Z")

</div>

Has anyone succeeded in running the Unix style “bash” shell in a Windows flavor container? (In other words: so that it can run Windows executables.)

I was hoping for msys2 to help me out, but as far as I have found until now, there is no way to run the installer in CLI mode, so I can’t have it installed.

I can install it on my desktop Windows PC and try to copy the installation into the Docker image, but the container crashes when I start it. I guess I see the reason: When it opens, it insists on running the bash shell in a new window, which can’t be done from a Docker container.

So has anyone out there succeeded in running any variant of bash in a container?

(What I am _really_ after is a shell that can run Windows executables _and_ has support for long filenames. It doesn’t necessarily have to be bash, but msys2 bash satisfies requirements on the desktop - I just can’t seem get it to work in a container!)

---

<div class="post-metadata">

**Author:** ![johnlbergqvist](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/johnlbergqvist/32/39725_2.png) [@johnlbergqvist](https://forums.docker.com/u/johnlbergqvist)\
**Post date:** [March 14, 2023, 1:02pm UTC](https://forums.docker.com/t/runing-bash-in-a-windows-container/85254/2 "2023-03-14T13:02:34Z")

</div>

I’ve managed to get an image to build, I used the Windows Chocolatey image:

```auto
FROM chocolatey/choco:latest-windows
RUN choco install git --version 2.39.2 --yes

RUN choco install jq --version 1.6 --yes
RUN choco install python --version 3.11.0 --yes
RUN choco install unzip --version 6.0 --yes
RUN choco install curl --version 7.88.1 --yes
RUN choco install sudo --version 1.1.3 --yes
RUN choco install awscli --version 2.11.2 --yes

# Append additional git directories to PATH
ENV ADD_PATH=";C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin"
# Update Registry key to append the above entries to PATH
RUN PowerShell Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value ((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path + "$Env:ADD_PATH")

```

As you can see i’ve installed git, which comes with git bash, and I made sure I added the additional git directories to the PATH.

When I ran the container interactively using `docker run -it <my-image> PowerShell`

I can see that PATH is set correctly, and that the other tools, such as git itself etc. are all available:

```auto
PS C:\> git --version
git version 2.39.2.windows.1

```

however weirdly `bash` itself just doesn’t seem to work at all, returning a non-zero exit code, no matter what arguments I give it:

```auto
PS C:\> git --version
git version 2.39.2.windows.1
PS C:\> $LastExitCode
0
PS C:\> bash --version
PS C:\> $LastExitCode
-1073741502
PS C:\>

```

So i’m struggling to work out why this isn’t working for me. Everything else seems to work (and git bash installed via chocolately on my local machine works fine)
