Skip to content

Source-executing init scripts may break entry point #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nanaya opened this issue Mar 23, 2020 · 2 comments · Fixed by #656
Closed

Source-executing init scripts may break entry point #651

nanaya opened this issue Mar 23, 2020 · 2 comments · Fixed by #656

Comments

@nanaya
Copy link

nanaya commented Mar 23, 2020

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
@nanaya nanaya changed the title Source-executing init scripts in may break entry point script Source-executing init scripts may break entry point Mar 23, 2020
@yosifkit
Copy link
Member

They've been sourced since the creation of the docker-entrypoint-initdb.d functionality (#90). We have contemplated allowing "initdb.d" scripts to be executed instead of sourced (like postgres docker-library/postgres#452), but just haven't gotten to it. 😱

@nanaya
Copy link
Author

nanaya commented Mar 23, 2020

So I guess similar "fix" should be applied here as well? After a cursory check it seems to involve updating all the script copies and then the documentation.

Although if it's me I might as well make it something like *.run.* (or *.run, or some other extension) to allow any type of executables and save pain for people expecting current behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants