bash - Run shell script inside a container -
i´m using lemonlatte / docker-webvirtmgr base file, problem there no ssh keys configured user www-data, wrote following shell script:
#!/bin/sh if [ ! -d "/var/local/webvirtmgr/nginxhome" ]; mkdir /var/local/webvirtmgr/nginxhome chown -r www-data:www-data /var/local/webvirtmgr/nginxhome usermod -d /var/local/webvirtmgr/nginxhome www-data su - www-data -s /bin/bash -c "ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -n ''" su - www-data -s /bin/bash -c "touch /var/local/webvirtmgr/nginxhome/.ssh/config && echo -e 'stricthostkeychecking=no\nuserknownhostsfile=/dev/null' >> /var/local/webvirtmgr/nginxhome/.ssh/config" su - www-data -s /bin/bash -c "chmod 0600 ~/.ssh/config" fi
after added 2 statements dockerfile:
add setupssh.sh /webvirtmgr/setupssh.sh run /bin/sh -c "/webvirtmgr/setupssh.sh"
i tried cmd /webvirtmgr/setupssh.sh, run /webvirtmgr/setupssh.sh no success...
when run script inside container hand working fine.
what wrong here?
greetings
update: here link repo of maintainer: link
update 2: build of dockerfile successful , put statement between:
run apt-get -ys clean <statements here> workdir /
the directory /var/local/webvirtmgr
defined volume.
volume /var/local/webvirtmgr
therefore directory mountpoint in running container , have added gets overwritten.
you have use different directory, script work.
here´s dockerfile test it:
from lemonlatte/docker-webvirtmgr run mkdir /var/local/webvirtmgr2 run touch /var/local/webvirtmgr2/t && touch /var/local/webvirtmgr/t run ls -la //var/local/webvirtmgr run ls -la /var/local/webvirtmgr2
output:
sending build context docker daemon 4.608 kb sending build context docker daemon step 0 : lemonlatte/docker-webvirtmgr ---> 18e2839dffea step 1 : run mkdir /var/local/webvirtmgr2 ---> running in d7a1e897108e ---> cc029293525e removing intermediate container d7a1e897108e step 2 : run touch /var/local/webvirtmgr2/t && touch /var/local/webvirtmgr/t ---> running in 1a1375651fa7 ---> e314c2529d90 removing intermediate container 1a1375651fa7 step 3 : run ls -la //var/local/webvirtmgr ---> running in 5228691c84f5 total 8 drwxr-xr-x 2 www-data www-data 4096 jun 6 09:22 . drwxr-xr-x 6 root root 4096 jun 6 09:22 .. ---> ec4113936961 removing intermediate container 5228691c84f5 step 4 : run ls -la /var/local/webvirtmgr2 ---> running in a6d2a683391a total 8 drwxr-xr-x 2 root root 4096 jun 6 09:22 . drwxr-xr-x 6 root root 4096 jun 6 09:22 .. -rw-r--r-- 1 root root 0 jun 6 09:22 t ---> 3cb98c5c1baf removing intermediate container a6d2a683391a built 3cb98c5c1baf
Comments
Post a Comment