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
docker-entrypoint-initdb.d is not working #160
Comments
I found an old backup of the very same machine mint 18.3 and same thing worked there. SO it's really hard to reproduce =(. I'll close this issue. |
@numbworks if you run this code manually inside the container, does it work at all?
Also note that this code will only run if the DB is not pre-initialized - but as you delete the volume this shouldn't happen. |
@tanji thank your for looking into this : ) bash --version:
for-deid.sh
for-deid.sh's output
It seems that runs the test .sh that I put inside docker-entrypoint-initdb.d just fine, but it doesn't run this piece "${mysql[@]}" < "$f" ?
And mariadb's user + password have been correctly created. Other information: "ls -l docker-entrypoint-initdb.d/" root@2af3df7188a0:/# ls -l docker-entrypoint-initdb.d/ "echo-test.sh
What I'll try is to configure my Raspberry Pi 3 in the following days, and see if it behaves the same way there. Thanks, |
Actually I want to re-open this issue. I just installed fresh machine using Linux Min 18.3 x64 and I can reproduce the issue. |
I tried 2 fresh installations of Linux Mint 18.2 and 18.3. In both cases it doesn't work. It looks like there is some broken package that gets installed during Docker installation process OR it's one of the docker images |
@numbworks I've rarely used the entrypoint.d function but I'll give it a shot and be back at you. BTW, you shouldn't use |
@numbworks Sorry I couldn't reproduce your issue. I ran the same Compose file with the following
This worked without any issues for me.
It is indeed different from yours, which has a |
@tanji you probably tried to reproduce it on a system where you already have docker installed. |
@skarpushin I'm sorry, your issue is completely different (the SQL didn't run, obviously...) and I didn't try to reproduce it. And I won't probably have no time for that, I'm not too familiar with Mint. |
@tanji , could you please clarify -- in which way it is different? |
@tanji Answers:
'/share/Container' is the default folder that QNAP assigns to Docker. a) they market their Docker-capability quite intensively (so I believe they did some QA on it); Next weekend I'll investigate further and share my findings. Thanks, |
Perhaps this docker-library/postgres#203 (comment) will help? In other words is the data directory empty when you start the container (the named volume from your compose)? The scripts are only run on first database creation; if you compose down/stop/kill and then |
Yup, I'm aware of that behaviour, and I always clean-up the volume before re-composing the container:
At a certain point I even did some |
UPDATE
I compared the Prod-env log with the Dev-eng log line-by-line, and here the differences. 1. ==========================Same in both logs:
2. ==========================Prod log:
Dev log:
3. ==========================Prod log:
Dev log:
4. ==========================Prod log:
Dev log:
|
@numbworks , that's for sharing this! So.. did you find how to fix that? |
@skarpushin |
UPDATE I also exported the Somebody on this thread has an idea how-to inject a custom The case #1 seems expecially peculiar, because it seems that, when Docker Compose reaches the point to run the custom All the other cases return a permission error (?). 1. =========================
2, 3, 4. =========================
|
UPDATE I did a counter-test. I added an un-supported file (.xlsx) to the
It doesn't appear.
|
Yep. And honestly I have NO idea, why. |
@skarpushin |
My current guess is permissions on the mounted folder. @numbworks gave this as his host permissions: drwxrwx--- 2 admin administrators 4096 2018-05-06 18:23 ./ When the entrypoint script gets to the point of reading the You can do a quick debugging test with the following. (It is running specifically as the mysql user so that we don't lose the $ docker run -d -e MYSQL_ROOT_PASSWORD=12345 --user mysql -v [volume-mount] mariadb:10.2 bash -x docker-entrypoint.sh mysqld The compose equivalent should be something like this inside the user: mysql
command:
- bash
- -x
- docker-entrypoint.sh
- mysqld |
@yosifkit
I'll give a try to your suggests in the weekend, and get back to this thread :) Rubèn |
Hey @numbworks , can you try running a "standard" docker-composer file ? command: ["mysqld", "--user=mysql", "--lower_case_table_names=1"] might have something to do with it as it overrides the command that the container would normally use. I wrote this simple .yaml and it did load the .sql found in the docker-entrypoint. services:
maria:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- "3306:3306"
volumes:
- ./maria:/docker-entrypoint-initdb.d/ For the .sql, I used the Chinnok Database and put it in a folder called maria alongside the docker-compose.yaml. |
@hydrocat |
@tanji compose-file reference seems to say otherwise
|
@hydrocat I haven't explained myself correctly. You can override the default container command (in this case for mariadb the default command is However, as the image uses an entrypoint, whatever override you use is always passed through the entrypoint. Full code here: https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh This way it's absolutely safe to override the command with additional options (unless, of course, you change the command by something else than |
Here's what I found. This may not apply to everyone, but it applied to me. Somewhere in the docker-entrypoint.sh, there's a block of code
For some reason this code dies but it doesn't log that it died. From that point on the rest of the script does not execute, none of your sql is ever executed and while the database is running, various things that should have happened don't (like setting a root password). Obviously setting |
This is happening to me exactly. Mysql container runs completely fine on my windows local environment but when I run it on the production linux server using docker-compose it will not load the script inside docker-entrypoint-initdb.d. Comparing the logs from my local machine and from the server I noticed two main differences, Production Server
Windows local machine
IN the prod server, it's saying there is an error in the sql syntax but I have no idea what it is referring to. I've used this exact setup on another server and it worked fine. I've tried changing the line endings on the script. I've checked the permissions they all seem to be fine. The script is physically copied into the container. I'm bashing my head against the wall here. This is the dockerfile that builds the container
|
I'll say I tried it again today with basically the exact same dockerfile and it worked fine. So it is intermittent somehow. |
Ok so I think I figured out the issue on my end, finally. I had a .env file set to be used with my docker-compose file and inside that .env file I had all the environment variables set for the mysql container, however I had them all set with "" quotations marks. I believe this was what was giving me the SQL syntax error in the above post. .env
I removed the quotation marks and everything seems to be working, I seriously hate this profession sometimes. Its always the simplest things. working .env
I haven't tried loading a .sql file yet, but that's next. I believe it should work now. |
After hours of trying to fix this problem, I found that if you use from your DockerCompose a volume to persist the data. If you want the docker-entrypoint-initdb.d to install your databases, you will need to remove the files from your volume in order to make this condition true. |
this fix my problem,hope useful to you |
Solved the problem for me |
Slightly embarrassing but wanted to post user error that I ran into incase it helped others here. I worked through this thread for several hours before I thought to view the DB as root.
My issue stemmed from running my dump with
Removing the schema info from the dump loaded the dump file successfully and I was able to view it as my added user. |
I had the exact same issue and solved it by making sure my mariadb container (version: 10.4) data volume is empty from any files or directories when I create the container from scratch. This is my docker compose file: mariadb:
image: mariadb:10.4
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ********
volumes:
- ./storage/db:/var/lib/mysql:rw
- ./app/db/SQL:/docker-entrypoint-initdb.d/:rw
ports:
- 3306:3306/tcp For me I just had to make sure this path: './storage/db' is empty from files. Please notice that the directory has to exists but be empty. |
Same issue here!
|
@mbtronics The same here. Thanks for your workaround, so when I add the environment variable, it runs again, but I think this has to be fixed. I can provide logs, if needed. Kind regards, |
@mbtronics This is the only solution that works for me. I spent a full day trying to figure this out. Thanks a lot! |
@mbtronics in my experience, the containers doesn't stop, it just takes a very long time to load the timezone info (+6 min.). It eventually comes trough and finishes the initialization. Btw, it's this command in docker-entrypoint.sh that's taking so long:
|
This is the best solution. |
Closing old issue since it seems like it was resolved (permissions?). Please open a new issue with lots details so we can reproduce the error. For those who fixed their problem by adding |
adding MYSQL_INITDB_SKIP_TZINFO=1 to my k3s mariadb deployment fixed the issue for me!! my dockerfile had the following... |
I have 2 virtual machines:
• One is based on Mint 18.2 Mate
• Other is based on Mint 18.3 Mate
On both I have installed Docker and Docker-compose.
On both
--version
shows same infoI'm invoking
docker-compose up
On 18.2 mapping for
docker-entrypoint-initdb.d
gets picked up and sql scripts are executed. But on 18.3 it doesn't happen and it's not even saying that file is ignored -- just nothing.I'm using the very same docker-compose file, you can check it out here: https://github.com/skarpushin/summerb/tree/master/src/summerb/summerb_tests_db
On 18.2 this section of log looks like:
On 18.3 this section of log looks like:
I just wasted 5 hours on thing which supposed to work everywhere the same way, but it doesn't. Please help to find out why and how to fix it.
The text was updated successfully, but these errors were encountered: