I am running Docker version 20.10.12, build e91ed57
I would like my Drupal development environment to stay intact even if I run a docker compose down, and then up again. I am able to get my local project up and running successfully. But when I run docker compose down, I have to re-install everything on the next docker compose up.
How can I improve my setup this way Drupal has a persistent database connection? Is there anything else that seems wrong or unneeded from my setup? Many thanks on helping me sharpening my docker compose skills!
The database connection cannot be persistent to survive docker-compose down. You actually want persistent data and not persistent connection. So @fouscou hint was good. Yes, I can see that you use volumes, but you have to make sure that you also have the right volumes for Drupal 8 and MySql too. MySQLâs volumes are probably right, so it should work.
Check if the database still have the data after docker-compose down
Check if every file which needs to be persistent is on volume. You can use docker container diff <containername> before and after
docker-compose down
docker compose up -d
Consider removing âmysql_dataâ from the depends_on list of drupal. I canât see any service in thet file called âmysql_dataâ. I tried, and the compose file works even with a non-existent dependency, but it may have some side effects.
An immportant question is whether you run docker-compose down only on drupal or MySQL too. None of them should be a problem, but knowing that can bring us closer to the solution.
One more small advice. If you work with Docker, you need to learn debugging and prepare yourself to investiagete situation like this . It means you check the existence and correctness of every configuration file, all data including the database records and the complete state of the container before and after stopping and starting the container again. If we canât help you, maybe the Drupal Community can tell you what is missing, if that is not explainable without knowing Drupal 8 and its files better.
Friends, many thanks on the good learning points here! I feel this is all good for me soak and journey through. Much appreciated on the support from everyone!