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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.