Doing a backup of your mysql container's DB can be automated just like any other task.
Script below is one way to do it.
You may or may not provide a parameter to the script and you'll always get the gzipped version of the backup + its sha256 checksum.
Sample Use Case: use it without parameters 1~$ ./backup_db.sh …
Sometimes, you may need to know which container a volume is associated with.
Use this command:
1docker ps -a --filter volume=VOLUME_NAME_OR_MOUNT_POINT See https://stackoverflow.com/questions/42857575/how-to-determine-what-containers-use-the-docker-volume
I encounter an issue where I don't have local composer installed but I need to run one.
Solution is to run it on the fly from docker container:
1docker run --rm --interactive --tty --volume <directory_path_to_your_composer.json>:/app composer install
Check first the names of your container:
1docker ps Technically though, it's just running a shell, so run as follows:
1docker exec -it <container-name> /bin/bash In case you see this error:
1OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: …
1docker logs <friendly-name|container-id> You can tail it much like tailing ordinary logs:
1docker logs -f --tail=5 <friendly-name|container-id> which means: "start tailing at current last 5 entries of the logs"
1[root@selenium02 ~]# docker rmi ad66a5961263 2Error response from daemon: conflict: unable to delete ad66a5961263 (must be forced) - image is being used by stopped container 088219585a61 3[root@selenium02 ~]# docker rmi -f ad66a5961263