Run SQL Server with Docker

 

Why

    1. Developer machines
      On my developer machines I have installed various version of SQL Server. These run services in the background and are difficult to stop and uninstall.Containers offer the opportunity to install then destroy and start again.
    2. Development and Testing
      Store images/containers and then recreate
    3. Future: create images which derive from base images and store and share in a repository possibly in Azure Container Registry

Get Started:

Install docker for windows

https://docs.docker.com/docker-for-windows/install/

Turn on virtualisation
Hyper-V
Docker

Quickstart: Run SQL Server container images with Docker

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017

Note on using PowerShell

Some docker commands do not work inside the ISE.
For those, or all commands use PowerShell console window

Connect from outside the container

From SqlCmd or SSMS

Use the IP address of the machine that hosts your container (probably your machine)
e.g. 10.0.0.21,1433

The function inspect gives information about the container, but not the host IP:
docker inspect

docker inspect –format ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ <container id>

 

 

Restore a database into the image

Now, we have SQL running in docker, it would be useful to restore a database into that.

  1. Outside Docker
    Backup database
    Tip: SSMS backup in UI, but then “Script action to new query window” and store it
  2. Copy file into the running image
    Use Bash
    docker exec -it sql1 “bash”Then Linux commands to make directory
    Exit Bash
    docker cp MyDatabase.bak sql1:\var\opt\mssql\backup
  3. Inside Docker
    Restore database – use script – may need to Move files

 

Bake files into an image for reuse

docker commit sql1 sqltestco:sql2017
docker images

Clean up with:
docker rmi sqltestco:sql2017

 

Use image to create docker images

Now we have an image with our database in it. We may want to use it once or many times.

Keep changing the name and the port
I found that –name needs to come first

docker run –name sqltestco1 -d -p 1434:1433 sqltestco:sql2017
docker run –name sqltestco2 -d -p 1435:1433 sqltestco:sql2017

Now have 3 instances of SQL running.

As needed:

docker start
docker stop
docker rm

 

Push images to Docker Hub

Use:
docker images
docker tag <imagename>:<tagname> <dockerId>/<repository>:<tagname>
docker login (good idea to spell everything correctly)
docker push <dockerId>/<repository>:<tagname>

Took a few attempts – got there. Private repository.

 

 

Troubleshooting

Seem to get a conflict if other containers exist but are stopped. Possibly good practice to be aware of all containers with:

docker ps -a

Error response from daemon: … userland proxy

Error response from daemon: driver failed programming external connectivity on endpoint … Error starting userland proxy: mkdir /port…

Restart docker – fixed it for me.

 

See also

Pluralsight : Getting started with Docker on Windows

https://app.pluralsight.com/library/courses/docker-windows-getting-started/table-of-contents

 

 

 

Advertisements

Create an ODBC using a reg edit file

With thanks to:

https://kencenerelli.wordpress.com/2012/07/26/export-an-odbc-data-source-from-the-registry/

Save following as a file e.g. MyODBCName.reg
Double-click to install into the registry


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
"MyODBCName"="SQL Server Native Client 11.0"

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\MyODBCName]
"Driver"="C:\\Windows\\SysWOW64\\sqlncli11.dll"
"Server"="MyServerName"
"Database"="MyDatabaseName"
"LastUser"="MyLastUserName"

How to keep the task bar visible when using a maximised RDP client

I use RDP a lot now, but would like to be able to see my own PC’s task bar, for instance Outlook may show messages.
It is possible, with thanks to:
http://notworthrepeating.blogspot.co.uk/2012/03/maximizing-remote-desktop-client.html

So:

  1. Edit your .RDP file using Remote Desktop Client, making sure the “Display” tab is configured for “Full Screen”, and then “Save” the .RDP file again (this bakes your local resolution into the file, which is important)
  2. Edit the .rdp in notepad:
    1. screen mode id:i:2  – change this line to the following, to use windowed mode instead of fullscreen
      screen mode id:i:1
    2. Add this line to the file if it doesn’t exist already:
      smart sizing:i:1
    3. Change nothing about (but take notice of) two lines that talk about “desktopwidth” and “desktopheight”
  3. Save and close the .RDP file

Thanks.

 

Device and Resource Redirection

https://technet.microsoft.com/en-us/library/cc725887(v=WS.10).aspx

Audio redirection

  1. Run
  2. Type “group” to open Edit group policy
  3. Local computer policy
  4. Computer configuration
  5. Administrative Templates
  6. Windows Components
  7. Remote Desktop Services
  8. Remote Desktop Session Host
  9. Device and Resource Redirection
  10. Allow Audio and video playback redirection
  11. Change from Not Configured to Enabled.

 

 

 

How to reinstate Contact Linking in Outlook 2013

For Outlook 2007 and 2010 there is an Option > Contacts > Linking > Show contacts linked to the current item

This has been removed in Outlook 2013, apparently because they have a new feature of Links when you are on People and the current view is People and then look at details. I don’t use that but and tend to use the List view which does not have the links. Also I have historic links, so wanted to reinstate links. Thanks to:

http://www.slipstick.com/outlook/2013/show-contact-linking-fields-in-outlook-2013/

Which I found via

http://www.outlook-tips.net/tips/tip-375-outlook-2007-contact-linking/

So steps copied from first of these are:

  1. Regedit
  2. HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Preferences
  3. Add DWORD: ShowContactFieldObsolete
  4. Set to 1

That page also referred to a Group Policy registry setting. I did not have that on my machine, did not create it and found that the links were there anyway

To remove:

Set to 0, or remove the Key

Solved.

 

MS Word 2013 ActiveDocument.MailMerge.OpenDataSource not available for reading on opening a document

A new PC has MS Office 2013 when the system still uses Office 2003 templates and vba code.

Error:

Don’t have actual text to hand, but something like:

“MailMerge.OpenDataSource is not available for reading”

 

Solution:

Programmatically change the view on open:

Private Sub Document_Open()
Me.ActiveWindow.View.Type = wdNormalView
End Sub

 

Found solution on web. Following was not the page, but similar

http://blogs.msmvps.com/wordmeister/2013/02/22/word2013bug-not-available-for-reading/

http://social.msdn.microsoft.com/Forums/expression/en-US/d68fe679-6a44-4437-b64a-ab6dfce4fa78/problem-with-activedocumentmailmergeopendatasource-read-only-words-documents-office-2013?forum=worddev

 

 

 

Office upload center upload failed permission issue

 

Sometimes Office upload centre just stops working.

Sometimes with failed permission, sometimes with

“OneDrive for Business found a problem while accessing the Microsoft Office Document Cache and needs to repair it before it can continue.
As part of the repair a copy of the cache will be saved as a backup and a new cache will be created.”

See also: http://community.office365.com/en-us/f/172/t/238998.aspx on time 5/14/2014 10:58 PM

If required then:

  1. Stop syncing
    http://office.microsoft.com/en-us/support/stop-syncing-a-library-with-skydrive-pro-HA102850041.aspx
  2. Rename folder as backup in case you lose files
  3. Stop related services in Task Manager Resources, including Groove, MSOSync or similar
  4. Clear cache
    http://community.office365.com/en-us/f/148/t/161576.aspxBrowse to “C:\Users\username\AppData\Local\Microsoft\Office\Spw” and delete all the content. You will see that this is all related to groove, and spw equals SharePoint Workspace.Go to “C:\Users\username\AppData\Local\Microsoft\Office\15.0\OfficeFileCache” and also delete all content from this folder. This is where all the caching from your files are stored.
    Note : Just try to delete all, if one or two items cannot be deleted, that’s OK.
  5. Sync again
    It may or may not allow you to choose a location

 

http://community.office365.com/en-us/f/148/t/215635.aspx

 

 

How to enable Azure VM IIS hosted website public access

  1. Setup IIS
  2. Confirm able to browse default website locally
  3. Azure Management Portal
  4. Select Virtual Machine
  5. Endpoints
  6. Add HTTP
  7. Confirm able to access the default site from a public web browser
  8. Optionally add FTP, HTTPS ( use for SSL )

Find and remove adware on Internet Explorer

Started getting adware underlined hyperlinks on IE today. This directs you to svr123.com and then on to a web advert

With thanks to http://geekvisit.com/remove-double-underlined-adware-rrfilter

Found in services and msconfig and disabled in both

  1. In RegEdit.exe delete following folder
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\RrFilterService64
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\yewimmxqbs64
  2. In Explorer
    %program files (x86)% delete folder Rr Savings
  3. In Explorer
    %program files% delete folder RrFilter
  4. Also in IE > Tools > Manage Add-ons
    Disable Adpeak – RrSavings
    Also More Information – Took a screen shot and noted the ClassID
  5. Searched for the ClassID in RegEdit and deleted it from a few 2-3 places

 

Azure Virtual Machines adding virtual hard disks VHD

See also Azure Powershell and Azure VM with SQL

If you have a Pluralsight subscription then they have a good course “Windows Azure Infrastructure as a Service Essentials” then chapter “Storage and Disks” and screen cast “Creating Virtual Hard Disks”

First create a local VHD

  1. Start – “Create and format hard disk partitions”
  2. Action Create VHD
  3. Set location, size, fixed size, OK
  4. Right-click on newly created disk and Initialise
  5. Think MBR – OK
  6. Detach VHD

Upload local VHD to Azure Storage using Azure Powershell

  1. Ensure that you can run local scripts, see Azure Powershell post
  2. Run script:
    add-azurevhd -destination http://<address&gt;.blob.core.windows.net/<container>/<blobname>.vhd -LocalFilePath :\vhds\VHD01.vhd

Set as Virtual Machines Disk

  1.  Azure management portal
  2. Virtual machines
  3. Disks
  4. Create, enter name, pick from storage, OK

Attach to the Virtual Machine

  1. Azure management portal
  2. Virtual machines
  3. Select machine
  4. Dashboard
  5. Attach – Attach disk
  6. Read/Write
  7. Tick, OK