Bash quirk in Dockerfile

In my last article I wrote about my initial experience with ECS, Docker and WordPress.

While already practical with the core concepts of Docker, after learning the basics of ECS and creating a working Dockerfile I encountered the need to dive deeper in many aspects of the “platform” and the technology under discussion.

One of the aspects that I wanted to investigate more about the technology, i.e. Docker, was related in particular to the Dockerfile optimizations and refactorings.

In the context of refactoring, one of the simple thing I wanted to do was to dry out the creation of some directories needed by NGINX.

To do that I relied on a bit of Bash and tried the following RUN:

RUN mkdir -p /var/cache/nginx/{client_temp,proxy_temp,fastcgi_temp,uwsgi_temp,scgi_temp}

Unfortunately it didn’t worked πŸ™

After a bit of googling around I found the explanation of my problem right here among the Docker issues.

As stated/reported by Vincent (thank you for that ;)) it seems that the problem was related in particular to my relying on Bash.

The fix?

Well it is already presented by Vincent πŸ˜‰

RUN bash -c 'mkdir -pv /tmp/{a,b,c}'

I hope this can be helpful for everyone facing the same problem I ecountered πŸ˜‰

Cheers!

Leave a Reply

wpDiscuz