Standard_init_linux.go:187: exec user process caused “no such file or directory”
Alpine + Docker + Bash
TL:DR bash
doesn't exist in Linux Alpine, you either use sh
or install it.
Today I was working on migrating our node application from the titanic (about 600mb) ubuntu:14.04 image to the much more compact node:8-alpine image that is based on Linux Alpine, a Linux distribution that is tiny and barebones, really barebones.
After setting everything up, cleaning the Dockerfile and setting up a node_modules dependencies cache. I build the image, and it was time to run it.
After deploying it to EC2, It was not booting and I kept receiving this error.
standard_init_linux.go:178: exec user process caused “no such file or directory”
It was working perfectly fine on our production environment, and I was sure that was an error introduced by my change.
It didn't say which file was missing, but I did know alpine doesn't have a lot of commands you would usually expect in most Linux distros.
So I ran an Alpine locally on my dev machine and ran every single command on my entryscript. Every single command was working.
So it began, I started googling the issue, and after many pages suggesting me to run dos2unix
without success. I ran into this.
So it looks like alpine is so barebones it doesn't even have bash
installed by default. It only has sh
and the first line of my script was #!/bin/bash
and docker tried to run my script with that shell. Because it wasn't found, it was throwing that really useless error. I lost a few hours of life on this.
The solution is quite easy, either change #!/bin/bash
to !#/bin/sh
or install bash with apk add --update bash
. And that is it.