Docker Community Forums

Share and learn in the Docker community.

How to start a container with volume mount

Docker version: Docker version 18.06.3-ce, build d7080c1

I want to start a stopped container with an added configuration like adding a volume mount.

I have stopped the container (Eg: Rancher container)
Commit that container into an Image
And finally created a container with the new image that has been committed earlier

But the container won’t start properly.

Error:
Could not start MySQL

The command I have used to start a container new image:

sudo docker run -d -v /home/next/rancher-bk:/var/lib/mysql --restart=unless-stopped -p 8080:8080 rancher/backup

For those who mount a local folder into a MySQL container, there is a warning in the docs: “The downside is that the user needs to make sure that the directory exists, and that e.g. directory permissions and other security mechanisms on the host system are set up correctly.” Did you consider all of this?

There are advantages and disadvantages, depending on what you need. I would suggest to read this Doc page from top to bottom. https://docs.docker.com/storage/bind-mounts/