You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My workflow for this project is progressive, so I add some SQL initialization data on my host OS, run sudo docker-compose down -v and then sudo docker-compose up. I did not update my user to not need the use of sudo for this scenario.
When I update the init.sh file, then these updates are reflected each time I run docker-compose up. The init.sql file however, only remembers the first "version" of this file. Any subsequent updates are ignored when running docker-compose up.
Things I tried
Tried sudo docker-compose up --renew-anon-volumes --force-recreate which also does not seem to help.
Tried pruning all the volumes with sudo docker volume prune. Does not help
Tried pruning the docker system with sudo docker system prune
What does work is if I copy the file and it's content to a new file name. Renaming the file does not work
So the question is simply, how do I get content updates of init.sql to be recognized by my docker compose setup?? I don't understand why changes to init.sh is picked up but changes to init.sql are ignored?
How to reproduce
Add the postgres section to a docker-compose.yml file
Add the scripts folder with an init.sh and init.sql file. The sql script can be anything, but below is what I used. The init.sh can have a bunch of echos.
Start container with docker-compose up
Make changes to the SQL file (e.g. add more insert statements or move table creation to the top)
Make changes to the .sh file
Run docker-compose down -v followed by docker-compose up
You will see in the logs that the updated init.sh script runs and an outdated version of init.sql runs!!
CREATETABLECUSTOMER (
ID SERIALPRIMARY KEY,
NAME VARCHAR(200)
);
SELECTNULLAS"Starting to insert into table CUSTOMER";
INSERT INTO CUSTOMER(NAME) VALUES ('Shiraaz Moollatjie');
CREATETABLEMAILING_LIST (
ID SERIALPRIMARY KEY,
NAME VARCHAR(200)
);
SELECTNULLAS"Starting to insert into table MAILING_LIST";
INSERT INTO MAILING_LIST(NAME) VALUES ('[email protected]');
COMMIT;
The text was updated successfully, but these errors were encountered:
So it turns out that the underlying file system is playing a role here when using Docker Volumes. I have been using a virtualbox vm and the project was sitting on a vboxsf file system. So when attaching a volume in my docker compose scenario(?), it has been attaching to a vboxsf volume this whole time.
When I moved the project from the vboxsf filesystem to something else (whatever my home directory filesystem has, ext4 I think) then updates to the files worked as expected.
I have a docker compose file that looks like this. (
postgres:alpine
is currently pointing at v10.3)The scripts folder looks like this:
The Problem
My workflow for this project is progressive, so I add some SQL initialization data on my host OS, run
sudo docker-compose down -v
and thensudo docker-compose up
. I did not update my user to not need the use of sudo for this scenario.When I update the
init.sh
file, then these updates are reflected each time I rundocker-compose up
. Theinit.sql
file however, only remembers the first "version" of this file. Any subsequent updates are ignored when runningdocker-compose up
.Things I tried
sudo docker-compose up --renew-anon-volumes --force-recreate
which also does not seem to help.sudo docker volume prune
. Does not helpsudo docker system prune
So the question is simply, how do I get content updates of
init.sql
to be recognized by my docker compose setup?? I don't understand why changes toinit.sh
is picked up but changes toinit.sql
are ignored?How to reproduce
docker-compose.yml
filescripts
folder with aninit.sh
andinit.sql
file. The sql script can be anything, but below is what I used. Theinit.sh
can have a bunch of echos.docker-compose up
docker-compose down -v
followed bydocker-compose up
init.sh
script runs and an outdated version ofinit.sql
runs!!The text was updated successfully, but these errors were encountered: