Search code examples
dockerdocker-composedockerfiledocker-machine

Switch between Docker Images


i need some help with docker on my mac. I have a container where i run an instance of mysql and i have created it one years ago and it worked very well until today. I have used Kitematic and i don't know why my mysql container was restarted wiped. Following this guide

https://timonweb.com/posts/getting-path-and-accessing-persistent-volumes-in-docker-for-mac/

I've found in this path

    linuxkit-025000000001:/var/lib/docker/volumes/41ba749910c92b2ab8e4d4a538fd6d15fad29864f2068f26629a8a7bddfcb53b/_data# 

the mysql folder with my tables. Can i repair this horrible mistake? Thank you.


Solution

  • Ok i have found a solution. Unfortunately as i can read online and in the Docker Documentation, on Mac Os X systems (i have Mojave) you can't access via /var/lib/docker/volumes folder because you must access via screen to view this folder, as you can read in the link in my answer. So i have done these things:

    • Open a terminal and use screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
    • You should see a blank screen, just press Enter , and after a while, you should see a command line prompt
    • Open another terminal and write docker run -it -v ~/Desktop:/Desktop <runs a container from an image> bash as you can read from the Docker documentation
    • The user’s ~/Desktop/ directory is now visible in the container as a directory under /
    • Create a file called testOrSo in home on this terminal
    • Come back to the other terminal and type find -name "testOrSo" and press enter now you have the right path to that image. Copy what you want (in my case a _data folder) in path that find show you and choose the Desktop folder mounted.
    • You can show your data on your Mac Desktop.

    I understand that it might not be a 100% perfect explanation or that there might be a faster method but so I solved my problem. I hope it can help!