Coder Social home page Coder Social logo

Comments (19)

friism avatar friism commented on July 2, 2024

You'll have to expose the correct port when running the container, eg.: docker run -p 1436:1433 -d sqlexpress

I find it to work - if in doubt you can always telnet <host> 1433 to make sure SQL Server is listening.

I don't think the browser service will be running - what do you need it for?

You can connect with SQL Server Management Studio with , 1433:

image

This is the Dockerfile that I use: https://github.com/Microsoft/Virtualization-Documentation/tree/master/windows-container-samples/windowsservercore/sqlserver-express/2014sp1

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

Ah, so you are using port 1436:1433 ? I assumed 1433:1433 (just wanted to confirm that wasn't a typo)

from dockerfiles-for-windows.

friism avatar friism commented on July 2, 2024

Oh, sorry - that was because I was testing running a bunch of them and exposing them on different ports on the host - you can run with 1433:1433

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

If I get a console on the container itself using powershell, how can I confirm the SQLExpress instance works at all using sqlcmd ? I've tried with something like this

Invoke-Sqlcmd -Query "SELECT @@VERSION" 

from dockerfiles-for-windows.

friism avatar friism commented on July 2, 2024

@toranb the port may not be available from inside the container (but not 100% sure) - you should be able to connect from whatever host you're on with SQL Server Management Studio.

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

When I get an interactive prompt on the SQLExpress container and I run Get-Service I can see that MSSQL is stopped (not running).

Have you seen this running WinServer2016 TP5 ?

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

Doing a little more looking - who actually registers this service during the install? I don't see a specific register-service in the dockerfile/or start files

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

screen shot 2016-06-01 at 6 40 55 pm

here is a screenshot showing what services are running in the container by default

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

screen shot 2016-06-01 at 6 46 23 pm

Here is the error I get trying to start that service myself

from dockerfiles-for-windows.

bucrogers avatar bucrogers commented on July 2, 2024

I, like friism, have found it to work under TP5, tested using the Azure "Windows Server 2016 Technical Preview 5" VM image

An alternative to telnet (which is not installed by default) within the running container is: "netstat -a"

In both the brogersyh and friism Dockerfiles: The SQL Express installer registers the windows-service; TCP/IP listener is configured.

In the brogersyh Dockerfile, start.ps1 copies the .mdf files to where they need to be (volume mount or non volume mount scenario) then starts service, using the default CMD

in the friism Dockerfile, the service is left in a running state during build - it comes up running regardless of what the startup CMD is

The only other networking-related issues I've seen are the Windows Firewall setting for whatever port you configure (1433 or otherwise) and for Azure, additionally, a firewall rule in the Network Security Group. An example of configuring both of these may be found at: Dockerfiles-for-windows-README: Azure Resource Manager Template

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

@brogersyh what does your netstat -an show? also, if you attach to your session and do Get-Service do you see the same "name" for SQL Server I show above (with the $ in it) ?

also, what did you use to "build" the container w/ docker run? did you pass in a special command to be run on boot the first time or ?

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

@brogersyh @friism just a quick update :) I was able to get SQLServer running today by coming in w/ docker run (using powershell) and doing start (the script) directly. yay :)

Next question - how "should" I do this w/ docker run because when I tried the following I got an error (so I had to powershell in instead)

docker run -it -p 1433:1433 sqlexpress "powershell ./start"

(this worked but the above did not)

docker run -it -p 1433:1433 sqlexpress powershell

edit

last question - when I come back to this after a host reboot and use docker start what should this full command look like to correctly "start" the SQLExpress server??

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

another quick question (non windows user so please forgive me)

if I'm at the powershell prompt in the container with SQL Server running what command can I use to connect and verify it's up? So far this won't work

sqlcmd -U sa -P thepassword2# -S localhost\SQLEXPRESS,1433

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

w00t! finally got connected :)

for anyone following along w/ me so far - here is the full command you need to run once you are on the box (using the SA password from this very repository)

sqlcmd -SLOCALHOST\SQL -Usa -Pthepassword2#

screen shot 2016-06-02 at 8 21 08 am

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

@brogersyh @friism thank you both for helping push me across the finish line :) just about gave up on this last night

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

another question for @brogersyh @friism

inside the SQL container itself netstat -an shows 1433 as expected - but in the host VM (winserver 2016 TP5) a netstat -an does not show the 1433 (yet docker ps does show the mapping is bound)

What does your host VM netstat show? do you see 1433 as I did in the SQL container itself?

from dockerfiles-for-windows.

Frannsoft avatar Frannsoft commented on July 2, 2024

I'm hitting this same issue. netstat -a shows the container is listening on 1433, but the host VM (winserver 2016 TP5) netstat -a does not show listening on 1433. docker ps shows the port is mapped.

@toranb Did you find a resolution?

from dockerfiles-for-windows.

toranb avatar toranb commented on July 2, 2024

@Frannsoft so I had 2 choices ...

  1. Connect w/ sqlcmd from host => to docker SQLExpress machine
  2. Verify the connection does work but w/ a simple utility

I spent a few min looking at what it would take to get sqlcmd installed on the host and decided to use option 2 instead so ... try this command to see if you get an error or not

(new-object Net.Sockets.TcpClient).Connect("THEIPADDR", 1433) //THEIPADDR here is the actual ip of the docker container using `netstat -a` I believe`

I noticed when the docker container didn't have SQLExpress running I would get a diff result so I think this actually worked but would love another set of eyes to confirm that assumption. Can you give that a try and report back?

from dockerfiles-for-windows.

Frannsoft avatar Frannsoft commented on July 2, 2024

This came back as connected (.Connected == true), which I did not expect. After some further investigation I tried connecting to the sql server instance using the container's internal IP address and specifying the port as well "[ipaddress],port"[instancename] and was able to connect!

Thanks for the kick in the right direction.

from dockerfiles-for-windows.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.