Copy Files to a Docker Container

One of the things that’s handy when working with containers is being able to move files in and out of the container. Certainly you can do this from a network share or other similar mechanism, but what about a straight copy?

Docker has a command with the cp parameter to do this.

docker cp WideWorldImporters.bak SQL17:/var/opt/mssql/data/WideWorldImporteres.bak

The structure is the from:to, separated by a space as two parameters. If you’re going to the host, then just the path and filename, or just name if the current folder) for the file. For the container, you need the container ID or name with a colon (:) and then the relative path.

A quick way to begin changing and customizing your containers by moving data in and out as needed.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , . Bookmark the permalink.