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,700 points
1,450 views

1 answer to this question.

0 votes

The latest express sqlserver images with setting

 ATTACH_DBs

environmental var works fine.

answered Dec 4, 2018 by Tyrion anex
• 8,700 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
• 10,620 points
1,710 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 20, 2018 in DevOps & Agile by Tyrion anex
• 8,700 points
957 views
+2 votes
1 answer
+2 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
• 58,020 points
2,739 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 30, 2018 in DevOps & Agile by Tyrion anex
• 8,700 points
1,234 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP