bash - Docker Entrypoint Why I get the wrong parameter -
i making custom docker image having dockerfile
# dockerfile moodle instance. # forked jonathan hardison's <jmh@jonathanhardison.com> docker version. https://github.com/jmhardison/docker-moodle php:7.0-apache maintainer dimitrios desyllas <ddesyllas@freemail.gr> #original maintainer jon auer <jda@coldshore.com> volume ["/var/moodledata"] expose 80 # let container know there no tty env debian_frontend noninteractive # moodle info env moodle_url http://0.0.0.0 env moodle_admin admin env moodle_admin_password admin~1234 env moodle_admin_email admin@example.com #database settings #supported 'pgsql', 'mariadb', 'mysqli', env moodle_db_type 'mysqli' env moodle_db_host '' env moodle_db_user '' env moodle_db_password '' env moodle_db_name 'moodle' env moodle_db_port '3306' run echo "installing php , external tools" run apt-get update && \ apt-get -f -y install mysql-client pwgen aspell unzip wget libxmlrpc-c++8-dev libxml2-dev libpng-dev libicu-dev libmcrypt-dev &&\ docker-php-ext-install mysqli && \ docker-php-ext-install pdo pdo_mysql && \ docker-php-ext-install xmlrpc && \ docker-php-ext-install mbstring && \ docker-php-ext-install zip && \ docker-php-ext-install xml && \ docker-php-ext-install intl && \ docker-php-ext-install soap && \ docker-php-ext-install mcrypt && \ docker-php-ext-install gd && \ echo "installing moodle" && \ wget https://download.moodle.org/download.php/direct/stable31/moodle-latest-31.tgz -o /tmp/moodle-latest-31.tgz && \ rm -rf /var/www/html/index.html && \ tar -xvf /tmp/moodle-latest-31.tgz -c /tmp && \ mv /tmp/moodle/* /var/www/html/ copy moodle-config.php /var/www/html/config.php copy ./entrypoint.sh /usr/local/bin/entrypoint.sh run chmod +x /usr/local/bin/entrypoint.sh # cleanup run apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/lib/dpkg/* /var/lib/cache/* /var/lib/log/* entrypoint /usr/local/bin/entrypoint.sh cmd ["/usr/sbin/apache2ctl", "-d", "foreground"]
but reason on following entrypoint.sh
script wrong parameter exec
#!/bin/bash echo "installing moodle" echo "fixing files , permissions" chown -r www-data:www-data /var/www/html find /var/www/html -iname "*.php" | xargs chmod +x echo "placeholder" > /var/moodledata/placeholder chown -r www-data:www-data /var/moodledata chmod 777 /var/moodledata echo "setting database" : ${moodle_db_type:='mysqli'} if [ "$moodle_db_type" = "mysqli" ] || [ "$moodle_db_type" = "mariadb" ]; set ${moodle_db_host:=$db_port_3306_tcp_addr} echo "waiting mysql connect.." while ! mysqladmin ping -h"$moodle_db_host" --silent; sleep 1 done echo "setting database connection info" : ${moodle_db_user:=${db_env_mysql_user:-root}} : ${moodle_db_name:=${db_env_mysql_database:-'moodle'}} : ${moodle_db_port:=${db_port_3306_tcp_port}} if [ "$moodle_db_user" = 'root' ]; : ${moodle_db_password:=$db_env_mysql_root_password} else : ${moodle_db_password:=$db_env_mysql_password} fi if [ -z "$moodle_db_password" ]; echo >&2 'error: missing required moodle_db_password environment variable' echo >&2 ' did forget -e moodle_db_password=... ?' echo >&2 exit 1 fi else echo >&2 "this database type not supported" echo >&2 "did forget -e moodle_db_type='mysqli' ^or^ -e moodle_db_type='mariadb' ?" exit 1 fi echo "installing moodle" php /var/www/html/admin/cli/install_database.php \ --adminemail=${moodle_admin_email} \ --adminuser=${moodle_admin} \ --adminpass=${moodle_admin_password} \ --agree-license exec "$@"
but on exec "$@"
"$@"
value docker's ip instead of comment start apache /usr/sbin/apache2ctl -d foreground
, cannot figure out why happen.
the original work in https://github.com/ellakcy/docker-moodle
remove set
in line set ${moodle_db_host:=$db_port_3306_tcp_addr}
script.
$ set set: set [-abefhkmnptuvxbchp] [-o option-name] [--] [arg ...] set or unset values of shell options , positional parameters.
Comments
Post a Comment