roasty
roasty

Reputation: 172

Is a Unix list not supported in Dockerfile?

I am changing the privileges on a few scripts before running them in the containers. I want to modify the script's permissions in one command.

This fails for the Dockerfile command:

RUN chmod +x {add, subtract}.sh

The following does work:

chmod +x *.sh

However, I do not want all the scripts in the local folder to have the execute permission.

Edit:

Here is the full Dockerfile:

FROM golang:1.12
COPY . .
RUN chmod +x {add, subtract}.sh

Upvotes: 0

Views: 52

Answers (1)

Perplexabot
Perplexabot

Reputation: 1989

It fails not only because of docker, but because it is invalid sh syntax. For the shell syntax portion, you want:

chmod +x {add,subtract}.sh 

Note the space is removed after the comma.

Furthermore, as per this, to allow for normal shell processing you need to modify the RUN command a little. To achieve what you want, do this:

RUN /bin/bash -c 'chmod +x /tmp/{add,subtract}.sh'

Tested with:

FROM golang:1.12
COPY add.sh /tmp
COPY subtract.sh /tmp
RUN /bin/bash -c 'chmod +x /tmp/{add,subtract}.sh'

Upvotes: 3

Related Questions