Closed devsquad-alvaro-meireles closed 1 year ago
It sounds like you want to mount a local path into the container so that a dump into that directory would be saved on your host system. Takeout does not offer a way to mount local paths. It only creates a default docker volume so that database data does not get lost when destroying a container.
By design, Takeout is opinionated in order to simplify the creation and destruction of service containers for developers that don't want to deal with the complexity of using vanilla docker commands.
What you are trying to do can be done with a little workaround. For example, you could grab the command that Takeout uses to enable your mysql container and add another -v
flag. An example command might look like this:
docker run -p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_ALLOW_EMPTY_PASSWORD=true \
-e MYSQL_ROOT_HOST=% \
-v mysql_data:/var/lib/mysql \
-v ~/Downloads:/var/downloads \
mysql/mysql-server:8.0.31-amd64 --default-authentication-plugin=mysql_native_password
Just note that creating a container manually like this means that Takeout has no knowledge of the container and cannot help enabling/disabling it. You would need to run vanilla docker commands to do that.
docker ps
to list containers
docker stop CONTAINER_ID
to stop containers
docker start CONTAINER_ID
to start containers
docker rm CONTAINER_ID
to remove containers
docker volume ls
to list docker volumes
docker volume rm VOLUME_NAME
to remove volumes
To add to this, I noticed that Takeout is now allowing passthrough parameters. However, there seems to be a small bug with that feature at the moment. I created a PR #302 to resolve this. Once we can get a fix merged in, it should be relatively simple to add a custom flag when enabling a container like so:
takeout enable mysql -- -v ~/Downloads:/var/downloads
Hey, @josecanhelp !
Thank you for your reply. I think your PR will allow doing what I want in Takeout.
I (and I think a lot of other devs) use this "behavior" to provide a way to easily restore database dumps inside a MySQL container: I copy the dump to the "~/Downloads"
, and after that, I access it in a container and when I navigate to the "/var/downloads"
I have my "~/Downloads"
from the host, that contains the dump.sql.
Hey, folks!
I want to know how I can use Takeout MySQL as a way to create a volume to share data between the container and the host. In my current dev environment I use something like that:
... So inside the container I have the: "/var/download" that is my "Download" folder, so I'm able to, for example, restore a database using a dump.
How I can have this same behavior using Takeout?