using ENTRYPOINT ["/sbin/my_init"] runs differently than CMD ["/sbin/my_init"]?

306 views
Skip to first unread message

Michael Dalpee

unread,
Dec 19, 2017, 9:51:03 AM12/19/17
to passenger-docker
I have a Docker image that uses phusion/baseimage.  In my dockerfile, if I use ENTRYPOINT ["/sbin/my_init"] and run the final image using:

 docker run --rm -t -i my_container

It works as expected and I get the following ouput:

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/rc.local...
Starting the Web Server
*** Booting runit daemon...
*** Runit started as PID 10
Spawning Xvfb
Allow anyone to connect to Xvfb
access control disabled, clients can connect from any host
=> Booting Puma
=> Rails 5.1.4 application starting in production 
=> Run `rails server -h` for more startup options
Capybara.threadsafe == true is a BETA feature and may change in future minor versions
Overwriting existing field _id in class ScrapeJob.
Overwriting existing field _id in class ScrapeJobStatus.
Overwriting existing field _id in class ScrapeSet.
[9] Puma starting in cluster mode...
[9] * Version 3.11.0 (ruby 2.4.2-p198), codename: Love Song
[9] * Min threads: 5, max threads: 5
[9] * Environment: production
[9] * Process workers: 2
[9] * Preloading application
[9] Use Ctrl-C to stop
[9] - Worker 0 (pid: 57) booted, phase: 0
[9] - Worker 1 (pid: 61) booted, phase: 0

However, if I simply change ENTRYPOINT to CMD (something I tried because I wish to deploy this to Heroku and Heroku demands that a CMD be present in the dockerfile) and run it the exact same way, I get this output:

/sbin/my_init: line 4: import: command not found
/sbin/my_init: line 5: import: command not found
/sbin/my_init: line 6: import: command not found
/sbin/my_init: line 7: import: command not found
/sbin/my_init: line 8: import: command not found
/sbin/my_init: line 9: import: command not found
/sbin/my_init: line 10: import: command not found
/sbin/my_init: line 11: import: command not found
/sbin/my_init: line 12: import: command not found
/sbin/my_init: line 13: import: command not found
/sbin/my_init: line 15: syntax error near unexpected token `('
/sbin/my_init: line 15: `KILL_PROCESS_TIMEOUT = int(os.environ.get('KILL_PROCESS_TIMEOUT', 5))'


Why is this different?  I thought these two commands, if specified individually, are equivalent.  I could not find anything on the web that indicates they run in different runtime environments. So I am quite confused.

Any help explaining this behavior would be much appreciated.



Reply all
Reply to author
Forward
0 new messages