Closed
Description
Initializing a container results in ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.
when a mounted file is missing from the host due to docker's behavior to create an empty directory for any missing mounted file.
root@8238788eac51:/# ls -la /docker-entrypoint-initdb.d/
total 8
drwxr-xr-x 3 root root 4096 Feb 15 19:09 .
drwxr-xr-x 58 root root 4096 Feb 15 19:32 ..
drwxr-xr-x 2 root root 68 Feb 15 19:09 database.sql
root@8238788eac51:/# for f in /docker-entrypoint-initdb.d/*; do echo $f; done
/docker-entrypoint-initdb.d/database.sql
Can a simple file test be added here?
mysql/5.5/docker-entrypoint.sh
Line 165 in 9898215
for f in $(find /docker-entrypoint-initdb.d/* -type f); do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
or
for f in /docker-entrypoint-initdb.d/*; do
if [ ! -f $f ]; then
echo "ignoring $f: not a regular file";
continue
fi
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
Edit: reorganized paragraphs