Create shared directory between host and already existing container

Hello,
I’m running a docker container (with MS SQL Server) on Ubuntu 22.04 (Docker 24.0.6)
For database backup, I need to share a directory between the container and the host.
I’ve read many posts related to this question: all are speaking about
docker run -v
I understand this command creates a new docker container.

My question is: how is it possible to use equivalent of docker run -v on an existing container ?

Kind regards,

Guy

Not possible. As we discussed it many times on the forum (you probably found some), a container should be recreatable any time. If you stored data in the container without a volume, you need to stop it, use docker cp to copy the data out, remove the container and create a new container with the bind mounted data. And in your case the backup directory.

Or the other not Docker related solution could be a remote share for which you would need to install the client (samba, nfs, s3) in the container and backup to the shared directory. That would be just a temporary solution since everything you installed would disappear when you recreate the container.

In your specific case with MS SQL, if you are using MS SQL 2022, as far as I know that supports saving backups to an S3-compatible object storage

I personally used MinIO for local S3 storage.

1 Like

Thank you very much for this explanation.