Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use docker image, without mounting the default volumes?

Tags:

docker

I want to use Docker MySQL.

docker run mysql

But I don't want to save data on the host machine. I want all the information to be protected inside the container. By default, this image created an unnamed volume, and attach it to the container.

Is it possible, to use the same container, (I don't want to create a new MySQL image from ground), but disable the volume?

In other words: Many Docker images in docker hub are using volumes by default. What is the easiest way to save all the data inside the container (so push, and commit will contain the data)? There is a command to stop a container, change it's Mounts settings, and start again?

I know that it is not best practice, my question is if it is possible.

like image 248
Aminadav Glickshtein Avatar asked Oct 29 '22 13:10

Aminadav Glickshtein


1 Answers

EDIT: There is a tool mentioned in the comments of the below thread that can edit docker image metadata, allowing you to remove a volume.

This is currently an open issue awaiting someone with the bandwidth to code it. You can track the progress here, with this link going directly to the applicable comment:

@veqryn since reopening this issue, nobody started working on a pull-request; the existing pull request did no longer apply cleanly on the code-base so a new one has to be opened; if anyone is interested in working on this, then things can get going again.

I too would like this feature! Mounting /var/lib/mysql/ on windows hosts with NTFS gives the volume root:root permissions which can't be chown'd; I don't want to add mysql user to the root group. I would like to UNVOLUME the /var/lib/mysql directory and replace it with a symlink that does have mysql:mysql permissions, pointed at /host/ntfs/mnt which is root:root 🤷‍♀️

like image 97
Evan Morrison Avatar answered Nov 15 '22 06:11

Evan Morrison