Hello,
The docker-compose.yml
file looks like this:
db:
image: mariadb:latest
container_name: db
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: rootsecret
MARIADB_DATABASE: laravel_db
MARIADB_USER: laravel_user
MARIADB_PASSWORD: secret
volumes:
- mariadb_data:/var/lib/mysql
- ./mysql/my.cnf:/etc/mysql/my.cnf
- ./file.sql:/docker-entrypoint-initdb.d/file.sql
ports:
- "3306:3306"
networks:
- app_network
After the container was started, I entered it with the command docker exec -it db bash and ran the following command:
# mariadb -u laravel_user -psecret laravel_db -e "SHOW TABLES;"
+------------------------+
|... |
| form_fields |
| form_orders |
| frequencies |
| gallery_products |
| job_batches |
| jobs |
| login_logs |
| migrations |
| option_form_orders |
| password_reset_tokens |
| permission_role |
| permissions |
| personal_access_tokens |
| products |
| remotes |
| roles |
| sessions |
| shell_colors |
| sizes |
| statuses |
| tab_forms |
| type_matrices |
| type_orders |
| units |
| users |
| vents |
| wax_guards |
+------------------------+
I stopped the container using the docker compose down -v
command and removed the line - ./file.sql:/docker-entrypoint-initdb.d/file.sql
. I restarted the container and logged into it and ran the following command and it had no output:
# mariadb -u laravel_user -psecret laravel_db -e "SHOW TABLES;"
#
I have a few questions:
1- Should that line always be present in the compose file?
2- If that line exists, then new data will be lost every time the container is restarted.
Thank you.