How to Copy a File from Host to Docker Container

Step-by-step tutorial on how to create a folder in a Docker container, then copy the WideWorldImporters sample database from your local file system to the Docker container.

If you need to restore a database backup file to a SQL Server instance that's running inside a Docker container (for example, on a Mac or Linux), you can copy the .bak file from your Mac/Linux machine over to the Docker container. Once the backup file is in the container, you can access it using SQL Server management tools, such as sql-cli or SQL Operations Studio.

  1. Download Sample Database (optional)

    This step is optional. If you already have your own file to copy, feel free to use that instead.

    Download WildWorldImportersDW-Full.bak [47.7mb] to your local machine.

    Screenshot of the WideWorldImporters webpage
  2. Create a Folder in Docker

    Let's create a new folder in the Docker container that we can place the .bak file into.

    Open a Terminal window and enter the following command:

  3. Copy the File to Docker

    Now we can copy the file to the Docker container.

    Enter the following command into your Terminal window:

    This assumes that you're in the same folder as the .bak file. If not, you can either use the full path to the file, or change directory (e.g. cd /Users/Bob/Downloads or whatever the name of the folder is that your backup file is in).

That's it! A copy of the .bak file should now be inside the Docker container. You can now go ahead and restore the database .bak file to SQL Server.