Docker for Windows error - Connecting a SQL Server database to a Docker container

0 votes

I’m using docker for windows on windows 10, and I’m running the below command in Powershell:

    docker run -d -p 1433:1433 -e sa_password=Infra_2017 -e ACCEPT_EULA=Y -v
    c:/infra_mvc_projects/SampleDb:c:/infra_mvc_projects/SampleDb -e
    attach_dbs="[{'dbName':'AdventureWorksDW2008R2_Data','dbFiles':
['c:\infra_mvc_projects\SampleDb\AdventureWorksDW2008R2_Data.mdf','c:\infra mvc_projects\SampleDb\AdventureWorksDW2008R2_Log.ldf']}]" microsoft/mssql-server-windows

I get the following error:

    VERBOSE: Starting SQL Server   
 docker : Sqlcmd: 'AdventureWorksDW2008R2_Data";CREATE DATABASE
    "AdventureWorksDW2008R2_Data" ON (FILENAME =
    N'c:\infra_mvc_projects\SampleDb\AdventureWorksDW2008R2_Data.mdf'),
    (FILENAME =
    N'c:\infra_mvc_projects\SampleDb\AdventureWorksDW2008R2_Log.ldf') FOR
    ATTACH ;"': Unexpected
    argument. Enter '-?' for help.
    At line:1 char:1
    + docker logs 673
    + ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Sqlcmd: 'Advent... '-?' for
    help.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    VERBOSE: Changing SA login credentials
    VERBOSE: Attaching 1 database(s)
    VERBOSE: Invoke-Sqlcmd -Query sp_detach_db
    "AdventureWorksDW2008R2_Data";CREATE
    DATABASE "AdventureWorksDW2008R2_Data" ON (FILENAME =
    N'c:\infra_mvc_projects\SampleDb\AdventureWorksDW2008R2_Data.mdf'),
    (FILENAME =
    N'c:\infra_mvc_projects\SampleDb\AdventureWorksDW2008R2_Log.ldf') FOR
    ATTACH ;
    VERBOSE: Started SQL Server.
Dec 4, 2018 in DevOps & Agile by Tyrion anex
• 8,280 points
85 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The latest express sqlserver images with setting

 ATTACH_DBs

environmental var works fine.

answered Dec 4, 2018 by Tyrion anex
• 8,280 points

Related Questions In DevOps & Agile

0 votes
1 answer
0 votes
1 answer

Error: Unable to access elasticsearch in docker for windows

This is simple, just follow the below ...READ MORE

answered Sep 3, 2018 in DevOps & Agile by Sophie may
• 9,050 points
25 views
0 votes
1 answer

Docker for windows error: Database lost on docker restart

If you are using docker-compose down/up, keep in ...READ MORE

answered Sep 19, 2018 in DevOps & Agile by Tyrion anex
• 8,280 points
21 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,100 points
56 views
0 votes
1 answer

How to a run deployed app in Docker for Windows?

To deploy an ASP.NET web application to ...READ MORE

answered Aug 29, 2018 in DevOps & Agile by Tyrion anex
• 8,280 points
73 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.