baseimage-docker: /etc/my_init.d/logtime.sh failed with status 127

Your sample sh with chmod +x

#In logtime.sh (make sure this file is chmod +x):
#!/bin/bash
/bin/date > /tmp/boottime.txt

RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh

docker run -i -t kunthar/middleware /sbin/my_init -- /bin/bash
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/logtime.sh...
*** /etc/my_init.d/logtime.sh failed with status 127
*** Killing all processes...

Whenever i comment out

ADD logtime.sh /etc/my_init.d/logtime.sh

everything is fine.

This is the explanation of status 127= http://is.gd/eKCtRI I’ve used

/bin/date > /tmp/boottime.txt

but no luck.

Any comments?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I think the problem was due to some invisible extra characters. I especially recommend ababkov’s comment here for anybody googling this problem.

FYI - this was coming back with “./run: file does not exist” for me for any services i attempted to add. When the script was run directly on the box, the following additional info was presented: “Invalid interpreter /#!/bin/sh^M” (or similar).

Issue ended up being dos vs unix line endings. Running the init files through from dos2unix / http://www.virtualhelp.me/linux/164-dos2unix-missing-ubuntu-1004 resolved the issue for me after 4 hours of head banging…

Thank you for your help! 😃