środa, 11 lutego 2015

Dockerfile - how to run bash script without using external files

The usual way of smuggling external scripts to docker image builds is by adding them from directory where Dockerfile is located (ADD command). But this cause a need to maintain external resources which is not so handy, especially when scripts are rather short. The workaround is to echo all the commands and pass them to sh:
RUN echo -e "su -c \"echo 'N' | hdfs namenode -format\" hdfs \n\
su -c \"hdfs datanode 2>&1 > /var/log/hadoop-hdfs/hadoop-hdfs-datanode.log\" hdfs& \n\
su -c \"hdfs namenode 2>&1 > /var/log/hadoop-hdfs/hadoop-hdfs-namenode.log\" hdfs& \n\
sleep 5 \n\
/usr/lib/hadoop/libexec/init-hdfs.sh \n\
killall java \n\
" | sh

Brak komentarzy:

Prześlij komentarz