docker - Why does container does't execite scripts inside /etc/my_init.d/ on startup? -
i have following dockerfile:
from phusion/baseimage:0.9.16 run mv /build/conf/ssh-setup.sh /etc/my_init.d/ssh-setup.sh expose 80 22 cmd ["node", "server.js"]
my /build/conf/ssh-setup.sh
looks following:
#!/bin/sh set -e echo "${ssh_pubkey}" >> /var/www/.ssh/authorized_keys chown www-data:www-data -r /var/www/.ssh chmod go-rwx -r /var/www/.ssh
it adds ssh_pubkey
env /var/www/.ssh/authorized_keys
enable ssh access.
i run container following:
docker run -d -p 192.168.99.100:80:80 -p 192.168.99.100:2222:22 \ -e ssh_pubkey="$(cat ~/.ssh/id_rsa.pub)" \ --name dev hub.core.test/dev
my container starts fine unfortunately /etc/my_init.d/ssh-setup.sh
script does't executed , i'm unable ssh container.
could me reason why /var/www/.ssh/authorized_keys
doesn't executed on starting of container?
i had pretty similar issue, using phusion/baseimage. turned out start script needed executable, e.g.
run chmod +x /etc/my_init.d/ssh-setup.sh
note:
i noticed you're not using baseimage's init system ( maybe on purpose? ). but, understanding of manifesto, doing forgoes whole "a better init system" approach.
my understanding want to, in case, move start command of node server.js
script within my_init.d
, e.g. /etc/my_init.d/start.sh
, in dockerfile use init system instead start command, e.g.
from phusion/baseimage:0.9.16 run mv /build/conf/start.sh /etc/my_init.d/start.sh run mv /build/conf/ssh-setup.sh /etc/my_init.d/ssh-setup.sh run chmod +x /etc/my_init.d/start.sh run chmod +x /etc/my_init.d/ssh-setup.sh expose 80 22 # use baseimage-docker's init system. cmd ["/sbin/my_init"]
that'll start baseimage's init system, go , in /etc/my_init.d/
, execute scripts in there in alphabetical order. and, of course, should executable.
my references are: running start scripts , getting started.
Comments
Post a Comment