Docker Community Forums

Share and learn in the Docker community.

Windows, .sh scripts, and the execute bit

(Dpratt71) #1

Since I think I’ve diagnosed my own problem, this is more of an FYI.

I tried to get this setup on Windows:

It failed with errors until I added some commands to the dockerfile along the lines of “RUN chmod +x /usr/bin/”. I was confused about why this was necessary, but the answer eventually came to me: If the .sh files were being copied from a Linux system, the execute bit would presumably be already set. But on Windows, there is no such thing as an execute bit for a file.

I’m not sure what is the right answer here. I considered the possibility that docker proper should remove all attributes when copying files on the assumption that one shouldn’t rely on them being set. But I’m not sure that makes sense and even if it did, it’d probably break the world. I also considered that maybe Windows docker should set the execute bit for such files, but that didn’t entirely sit well with me either.

(Pcarrier) #2

This is a must have for some of our tooling and build toolchains.

Tarballs are produced and we check that we have the executable bit. It’d be better to always have the bit set, but what would be great would be to store that in attributes (even better if Cygwin and/or the os package in Golang would agree to the convention) as otherwise everything would be executable which happens to work for my very specific needs but isn’t exactly satisfying.

(Dockerklewis) #3

I too would like to know how we create and reference an executable script file, within a Dockerfile, if we are in Windows, using a terminal.