Skip to content

Conversation

@lalyos
Copy link
Contributor

@lalyos lalyos commented Jul 16, 2018

The for loop calling process_init_file in docker-entrypoint.sh silently skips if there are permission issues.

Initializing

the official docs abour initializing-a-fresh-instance instructs to bind mount the /docker-entrypoint-initdb.d/ dir:

docker run \
  -d \
  --name db \
  -e MYSQL_DATABASE=mydb \
  -e MYSQL_ROOT_PASSWORD=secret \
  -v $PWD:/docker-entrypoint-initdb.d/ \
  mysq

the for cycle on a non readable directory (mode 600) silently skips the loop body, leaving the user wonder what's wrong with scripts.

Proposed fix

by adding an extra ls command would produce an error message:

ls: cannot open directory '/docker-entrypoint-initdb.d/': Permission denied

@tianon
Copy link
Member

tianon commented Jul 30, 2018

I'm OK with this, but I don't understand the purpose of [ -e /docker-entrypoint-initdb.d/ ], and I'd prefer to send the output of ls to /dev/null (since we only care about it generating a useful error message for us -- we don't actually want the output of ls).

@lalyos
Copy link
Contributor Author

lalyos commented Jul 30, 2018

Hi, @tianon, the purpose of [ -e /docker-entrypoint-initdb.d/ ] is to only try to ls if the directory exists, otherwise every container, which doesn't bind anything to /docker-entrypoint-initdb.d/ would fail.

stdout of ls is redirected to /dev/null

@tianon
Copy link
Member

tianon commented Jul 30, 2018

Right, that's what's got me confused -- it'd be pretty unique for someone to not have that directory existing, given that it's created in the base:

RUN mkdir /docker-entrypoint-initdb.d

@tianon
Copy link
Member

tianon commented Jul 30, 2018

(And in that case, I think it's totally appropriate for folks to get a harmless ls error.)

@lalyos
Copy link
Contributor Author

lalyos commented Jul 30, 2018

Ohh i see, that makes more sense. I just removed the extra check.

@tianon
Copy link
Member

tianon commented Jul 30, 2018

Once Travis is happy again I think we're good to merge. 👍

@tianon tianon merged commit 333935a into docker-library:master Jul 30, 2018
tianon added a commit to infosiftr/stackbrew that referenced this pull request Jul 30, 2018
- `bash`: tianon/docker-bash#11
- `cassandra`: docker-library/cassandra#153
- `ghost`: docker-library/ghost#140
- `haproxy`: 1.8.13
- `httpd`: docker-library/httpd#106
- `mongo`: docker-library/mongo#289
- `mysql`: 5.7.23, 8.0.12, 5.5.61, 5.6.41, generate error on inability to read `initdb.d` files (docker-library/mysql#453)
- `openjdk`: update `latest` to OpenJDK 10 (docker-library/openjdk#220)
- `owncloud`: docker-library/owncloud#104
- `percona`: update to Stretch (docker-library/percona#67)
- `postgres`: `11~beta2-2.pgdg90+2`
- `rabbitmq`: docker-library/rabbitmq#270
- `rocket.chat`: 0.68.0
- `tomcat`: docker-library/tomcat#127
- `wordpress`: `WORDPRESS_CONFIG_EXTRA` (docker-library/wordpress#142), docker-library/wordpress#321

So, mostly instances of docker-library/php#666 with a few other changes mixed in.
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 this pull request may close these issues.

2 participants