Skip to content

Source-executing init scripts may break entry point #651

Closed
@nanaya

Description

@nanaya

The way scripts are executed in docker-entrypoint.sh

*.sh) mysql_note "$0: running $f"; . "$f" ;;

may cause breakage because it affects the parent (entry point) script.

It should be updated to either be just "$f" (or /bin/sh "$f") or properly document that the scripts are run by sourcing so people won't accidentally set stricter environments or overrides defined functions.

To reproduce:

  1. clone and enter https://github.com/nanaya/docker-mysql-init
  2. docker-compose up
edho@ubuntu:~/tmp/dbtest$ docker-compose down
Removing dbtest_db_1 ... done
Removing network dbtest_default
edho@ubuntu:~/tmp/dbtest$ docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
dbtest_database

Total reclaimed space: 184.6MB
edho@ubuntu:~/tmp/dbtest$ docker-compose up
Creating network "dbtest_default" with the default driver
Creating volume "dbtest_database" with default driver
Creating dbtest_db_1 ... done
Attaching to dbtest_db_1
db_1  | 2020-03-23 10:24:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
db_1  | 2020-03-23 10:24:47+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1  | 2020-03-23 10:24:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
db_1  | 2020-03-23 10:24:48+00:00 [Note] [Entrypoint]: Initializing database files
db_1  | 2020-03-23T10:24:48.057816Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1  | 2020-03-23T10:24:48.057890Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 41
db_1  | 2020-03-23T10:24:52.115367Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
db_1  | 2020-03-23 10:24:56+00:00 [Note] [Entrypoint]: Database files initialized
db_1  | 2020-03-23 10:24:56+00:00 [Note] [Entrypoint]: Starting temporary server
db_1  | 2020-03-23T10:24:56.719766Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1  | 2020-03-23T10:24:56.721198Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 91
db_1  | 2020-03-23T10:24:57.824202Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1  | 2020-03-23T10:24:57.845360Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1  | 2020-03-23T10:24:57.914223Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
db_1  | 2020-03-23 10:24:57+00:00 [Note] [Entrypoint]: Temporary server started.
db_1  | 2020-03-23T10:24:58.092776Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock'
db_1  | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1  | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
db_1  | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1  | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
db_1  | 2020-03-23 10:25:01+00:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: baLingoosh9SheeghooB8Ahsiicioseu
db_1  |
db_1  | 2020-03-23 10:25:01+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/0-runme.sh
db_1  |
db_1  | 2020-03-23 10:25:01+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/1-runme.sql
db_1  | /usr/local/bin/docker-entrypoint.sh: line 192: $1: unbound variable
dbtest_db_1 exited with code 1
edho@ubuntu:~/tmp/dbtest$ docker-compose --version
docker-compose version 1.25.4, build 8d51620a
edho@ubuntu:~/tmp/dbtest$ docker --version
Docker version 19.03.8, build afacb8b7f0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions