phusion / baseimage-docker

A minimal Ubuntu base image modified for Docker-friendliness
http://phusion.github.io/baseimage-docker/
MIT License
8.96k stars 1.09k forks source link

Startup scripts return error code 127 #213

Closed ondrowan closed 9 years ago

ondrowan commented 9 years ago

Any shell script I put into /etc/my_init.d/ folder is returning error code 127 for me. I've tried exact setup from readme, custom scripts, empty file, different baseimage versions. Everything with the same results.

This is my current setup:

Dockerfile

FROM phusion/baseimage:0.9.16

CMD ["/sbin/my_init"]

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

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

logtime.sh

date > /tmp/boottime.txt

Logs

$ docker run -d --name test test
c7b7d721edec4685dbcb25a37f93c908c4b8a11ead9c5df93aa6614c79b65aca
$ docker logs -f test
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
No SSH host key available. Generating one...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
invoke-rc.d: policy-rc.d denied execution of restart.
*** Running /etc/my_init.d/logtime.sh...
*** /etc/my_init.d/logtime.sh failed with status 127

If I start the container with --skip-statup-files and run /etc/my_init.d/logtime.sh, it returns error code 0 as expected.

ondrowan commented 9 years ago

Of course I forgot #!/bin/sh at the beggining of the shell script. Everything works fine now.