Archive

Author Archive

Ubuntu 17 reset

I had an Ubuntu vm (Hyper-V) with troubles, as the software updater gone after an uninstall of double items that i don’t figure how were generated, Docker not working (continuously launching mySQL containers immediately expired).
Before the deleting of the vm i tried with success:
Delete the Docker folders

service docker stop
rm -rf /var/lib/docker/containers/*
rm -rf /var/lib/docker/vfs/dir/*
service docker start

Configuration of unconfigured packages:

dpkg --configure -a

Update repositories

apt-get update

Fix missing dependencies:

apt-get -f install

Update system:

apt-get dist-upgrade

Reinstall Ubuntu desktop:

apt-get install --reinstall ubuntu-desktop

Remove unnecessary packages:

apt-get autoremove

Clean downloaded packages already installed:

apt-get clean

Now Docker has no more problems, the Ubuntu updater is working, it seems all ok.
I discovered this Resetter, but i would try this only as a last desperate resource before the total reinstall from scratch.

Advertisements
Categories: Ubuntu, Docker

Still on Docker for Windows

In this previous post i wrote about the connection from the Docker host to a local container.
Ok, but for the connection from another host? the Windows 10 host is in the subnet 192.168.0.xx, the container has a subnet 172.
So the host can ping the container because the virtual network between host and container, but it is private: no way that another host can ping the container.
My first attempt was to use the Hyper-V network used from the Hyper-V host in order to give connection to the VMs (converted from VmWare Workstation with WinImage): so the External network in my Hyper-V is named “exvmware”

I thought: if I’m able to use “exvmware” instead of the default network…
But without hope:

docker run -d -p 1433:1433 --network=exvmware --ip 192.168.0.5 --name sqlcontainer1 --hostname thorsql -v G:\DbAndMail:c:\data -e sa_password=<somepwd> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

causes error:

docker: Error response from daemon: user specified IP address is supported only when connecting to networks with user configured subnets.

Having some troubles with the network interfaces i followed the instructions in this discussion: in practice i downloaded this PowerShell script and launched

.\CleanupContainerHostNetworking.ps1 -Cleanup -ForceDeleteAllSwitches

After i tried a

docker network create -d transparent mynet

because i was thinking to create a “transparent” network that seems can permit communications with the containers from another host, but i got:

Error response from daemon: HNS failed with error : Element not found.

Uninstalled Docker and reinstalled, still no way to create the network… i remember that was working.
Finally i tried

docker run -d -p 1433:1433 --network=exvmware --name sqlcontainer1 --hostname thorsql -v G:\DbAndMail:c:\data -e sa_password= -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

That is without specifying the IP, and surprise, it worked!
A Docker inspect was revealing that there was no ip:

"Networks": {
	"exvmware": {
		"IPAMConfig": null,
		"Links": null,
		"Aliases": [
			"<containerid>"
		],
		"NetworkID": "18e....",
		"EndpointID": "ab2....",
		"Gateway": "",
		"IPAddress": "",
		"IPPrefixLen": 0,
		"IPv6Gateway": "",
		"GlobalIPv6Address": "",
		"GlobalIPv6PrefixLen": 0,
		"MacAddress": "00:…",
		"DriverOpts": null
	}
}

Argh.. and now?
But if this damn SQL is running.. no way to reach him? i explored the network with Advanced IP Scanner and surprise:

192.168.0.7 ?? (192.168.0.77 is the Docker host, my ASUS notebook).. but Docker inspect says that there is no IP…
Effectively now i can ping “thorsql” from the Docker host, another real desktop, another Hyper-V vm and it responds 192.168.0.7.

The only problem comes if i stop the container, and then relaunch with

docker start -ai <containerid given from docker ps -a>

The IP changes, but fortunately it can used the container hostname: i should investigate if is possible to maintain the IP.
So at the end i caused some troubles with the PowerShell script, securely it was not needed and could be it causes troubles on a pc which is a Docker Host and also a Hyper-V host: anyway i don’t need to create Docker networks at the moment and is my development pc.
But i know, pc formatting at the horizon.

Categories: Docker

SQLDMO for older programs


Sometimes i must maintain ancient software, Visual Basic 6 applications of the last millennium.
I still wondering why opening an Visual Basic 6 project after some years, i remember that was all ok and i’m the only one in the world that opens this ancient vm, magically some DLL reference is no more working.
So some code that was using SQL-DMO was causing the error “can’t create the object”.
In a folder there was a sqldmo.dll, no way to register/unregister, delete and the add the reference.
Fortunately i found this download, after the install pointing the dll reference to c:\Programs\Microsoft SQL Server\80\Tools\binn\sqldmo.dll (is a Windows XP vm…) my program can run; by the way connecting to SQL Server 2016 Developer inside a Docker Windows container.

Categories: SQL Server, Visual Basic 6

SQL Server Developer 2016 containerized under Docker for Windows

Until the last format of my notebook (end of August: there was no way to repair Office 2016 , and after i got a malware from the infamous CCleaner 5.33) SQL Server Developer was installed with the other programs.
But this time my approach was “no more VmWare Workstation” because it conflicts with Hyper-V needed from Docker.
Currently i’m ok with Hyper-V even if there are issues, as the access from the vm to the host that i resolved with the mapping of the host disks as “Local resouces” in the remote desktop connection: not the better approach, but for me works.
Then I decided to use SQL Server 2016 Developer in a container: could be that one day in my pc there will be only Windows 10, Hyper-V, Docker and all of the programs (Office, Visual Studio, Android Studio, SQL Server..) will be containerized?
Installed Docker for Windows, i opened a cmd shell and launched

c:\>docker pull microsoft/mssql-server-windows-developer

After some Gb of download, the Docker page tell us that we can launch

c:\>docker run -d -p 1433:1433 -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

Well, at this point our server is running, the sa user password was initialized to the passed value and i can do

c:\>docker ps
CONTAINER ID        IMAGE                                   <other columns..>
5fd521dc8565        microsoft/mssql-server-windows-developer

We have the CONTAINER ID that we can use for connecting to our instance, for example (note that we can use the entire CONTAINER ID but also only the first 3 chars)

docker exec -it 5fd sqlcmd -S. -Usa -P<SA_PASSWORD>

and if all is ok we can see the SQLcmd prompt, launch some commands:

1> select @@version
2> go
                                                                                                                                                                                      
------------------------------------------------------------------------------------
Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64)
        Oct 28 2016 18:17:30
        Copyright (c) Microsoft Corporation
        Developer Edition (64-bit) on Windows Server 2016 Datacenter 6.3 <X64> (Build 14393: ) (Hypervisor)


(1 rows affected)
3> Quit

Ok well, but at this point I would use SQL Server Management Studio, use my MDF files that are in the main pc filesystem.
First of all, by default the containers change the container name (sometimes with hilarious names, as “drunken_borg”) and the IP, which is tipically a private IP network 172.xx.xx.xx.
If you do a

c:\>docker stop 5fd

and then relaunch the “docker run” you will see (with a docker inspect CONTAINER_ID) that the container name and the IP are changed, and if some services rely on your SQL is a problem.
But for the moment we connect from SQL Management studio on the host, if our server has IP 172.26.80.30 we would try

But without success, we have an error about the certificate chain:

After some head scratching, i finally found that we need to set in Options >> Additional Connection Parameters this magic setting, TrustServerCertificate=True:

Done this, we can finally see our server:

But if we try to attach our MDF files that are in the host, no way, we can explore only the local c: (of the containerized Windows Server which runs our SQL instance)

The solution is to use the Docker Volume parameter: we need to changes some parameters in the SQL server starting, so close SQL Management Studio, run a

c:\>docker stop <CONTAINER ID>

and then

c:\>docker rm <CONTAINER ID>

The new command is:

c:\>docker run -d -p 1433:1433 --name sqlcontainer1 –hostname mysqlhost --ip 172.26.80.30 -v G:\DbAndMail:c:\data -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

In this command:

-p 1433:1433 : maps the local port 1433 to the 1433 port of the container

–name mysqlhost: we will have our defined host name, no “drunken_borg”

–ip 172.26.80.30: we define a fixed IP for our instance, so the connected clients that uses our SQL can rely on a certain value

-v G:\DbAndMail:c:\data : we map the host path G:\DbAndMail on the container c:\data; the path inside the container will be created if not exists.

Entering in SQL Management Studio, we can this time explore our host path mounted in c:\data in order to attach the already existents MDF files.


At this point if we launch

c:\>docker stop <CONTAINER ID>

and then

c:\>docker run -d -p 1433:1433 --name sqlcontainer1 …

Docker complains that sqlcontainer1 already exists, we need a docker rm.
But in this manner we lose the changes, if we attached an existing MDF in the previous SQL Management Studio session every previous change in the SQL data is maintained but we must re-attach the MDF, every configuration change for example

exec sp_configure "remote access", 1
reconfigure

is lost: is another instance.
So we need to see the NEW_CONTAINER_ID with

c:\>docker ps – a 
CONTAINER ID        IMAGE                                      …
05e581c12329        microsoft/mssql-server-windows-developer …

where we can see the stopped containers, and then launch

c:\>docker start -ai  05e
CONTAINER ID        IMAGE                                      …
05e581c12329        microsoft/mssql-server-windows-developer …
where we can see the stopped containers, and then launch
c:\>docker start -ai  05e
VERBOSE: Starting SQL Server
VERBOSE: Changing SA login credentials
VERBOSE: Started SQL Server.

TimeGenerated          EntryType Message
-------------          --------- -------
9/26/2017 4:55:56 PM Information Software Usage Metrics is enabled.
9/26/2017 4:55:55 PM Information Recovery is complete. This is an informatio...
9/26/2017 4:55:55 PM Information Service Broker manager has started.
9/26/2017 4:55:55 PM Information The Database Mirroring endpoint is in disab...
9/26/2017 4:55:55 PM Information The Service Broker endpoint is in disabled ...
9/26/2017 4:55:55 PM Information The tempdb database has 2 data file(s).
…

We can see that in SQL Management Studio nothing was changed, we find our previously attached MDF and other changes.

Categories: Docker, SQL Server

Update Android Studio project – Gradle issues

Last year i worked to an Android Studio project, now i should make changes and reopened Android Studio after some months.
Obvious, there were a lot of updates and Gradle began to complain about the settings, recommending changes.
The best approach is to copy the current Gradle section in some text editor, delete the lines below compile ‘junit:junit:’, right clic on App node and choose “open Module Settings”

Here on Dependencies Tab clic the green “+” and add a library dependency

then search :

So are catched the right versions.

Categories: Android

Use Python 2.7 in Spyder

Installing the Python Development with Visual Studio 2017

is available Anaconda, a Python data science platform.
Inside Anaconda are installed some packages as Spyder, an useful IDE for Python that typically uses the latest Python (3.6).
But there are environments as Multichain where is requested Python 2.7.
In order to have Spyder working with Python 2.7 follow these steps:
launch the Anaconda command prompt, at the prompt type these 3 commands:

conda create -n spyder python=2.7 spyder
conda activate spyder
spyder

And Spyder is launched using Python 2.7

Categories: Multichain, Python

Problem with MacOS downloaded programs


I tried this morning to install Docker on MacOS (Sierra) , downloaded the .dmg file and double clicking on it, i got a message complaining that the app is damaged and can’t be opened.
And strange thing, the same with older .dmg that i was installing without problems: could be an recent update.
After some search i found this page and effectively trying

sudo spctl --master-disable

i can open the .dmg and install Docker.

Categories: Docker, OSX

Differences in browsers engines under AngularJS

Working to updates on a AngularJS site, i discovered subtle differences.
I don’t know if there were these problems before, but certainly they raised while testing with Angular 1.6.5
First, if the user was switching the site language from English to Italian while working , saving a date Moment was not able to parse the date giving “Invalid date” using the latest Chrome and Firefox, while with Ie11 and Edge all ok.
In origin the code was (oh yeah, it uses the DOM objects instead of the binding..)

var testDate = moment($("#txtBirthDate").val()).format($scope.DateFormat.toUpperCase());
if (testDate === "Invalid date") {
    logWarning(localize.localizeText("DateNotValid"), null, true);
    $("#txtBirthDate").focus();
    return false;
}

For the first thing , using Visual Studio 2017 and starting the project i noticed that finally the breakpoints in javascript code are working also under Chrome, great thing:

Obvious , $scope.DateFormat.toUpperCase() is evaluated at runtime as YYYY-MM-DD for English and DD/MM/YYYY for Italian.
In order to work also with Chrome and Firefox this is the correct Moment syntax:

var testDate = moment($("#txtBirthDate").val(), $scope.DateFormat.toUpperCase()).format($scope.DateFormat.toUpperCase());

This code instead works without changes in all browsers:

var datBirthDate = moment($("#txtBirthDate").val(), $scope.DateFormat.toUpperCase()).toDate();
var BirthDate = datBirthDate.yyyymmdd();  // as requested for SQL Server

Then the other issue, an awkward issue.
The customers have the bad habit to press F5 or worse the browser refresh button in the pages, that in Angular does little sense.
In the site the other controllers (the ones not relatives to the home page) are loaded with ocLazyLoad (current version v1.0.10), in config.route.js the code was

}, {
    url: '/phones',
    config: {
        title: 'Phones',
        role: 'Administrator;PowerUser;User',
        templateUrl: 'app/tabelle/phones.html', 
        resolve: requireDependencies(['app/services/datacontextphones.js'], ['app/tabelle/phones.js']]),
        settings: {
            content: '<i class="fa fa-mobile"></i> {placeholder}',
            nav: 3,
            localizeKey: 'mnuPhones',
            minicontent: '<i class="fa fa-mobile" title="{placeholder}"></i>'
        }
    }
}, {

The function:

function requireDependencies(depContext, depMain) {
    return {
        resolvedData: ['$q', '$rootScope', '$ocLazyLoad', function ($q, $rootScope, $ocLazyLoad) {
            $ocLazyLoad.load(depContext);
            $ocLazyLoad.load(depMain);
        }]
    };
}

and this code with Ie11 and Edge was working fine, the users could hit F5, the browser refresh button, and the page is refreshed without problems.
Instead with Chrome and Firefox:

After some struggle, the working code in config.route.is that doesn’t use the function requireDependencies and all pages are surviving to the refresh in all browsers:

}, {
    url: '/phones',
    config: {
        title: 'Phones',
        role: 'Administrator;PowerUser;User',
        templateUrl: 'app/tabelle/phones.html', 
        resolve: {
            deps: ['$ocLazyLoad', function ($ocLazyLoad) {
                return $ocLazyLoad.load({
                    name: "phones",
                    files: [
                        'app/services/datacontextphones.js',
                        'app/tabelle/phones.js'
                    ]
                });
            }]
        },
        settings: {
            content: '<i class="fa fa-mobile"></i> {placeholder}',
            nav: 3,
            localizeKey: 'mnuPhones',
            minicontent: '<i class="fa fa-mobile" title="{placeholder}"></i>'
        }
    }
}, {

Categories: .NET, Angular, Javascript, Vs2017

Dockerize .NET Core 2 Web App

Recently Microsoft officially announced .NET Core 2.
Installing the SDK in Visual Studio 2017 is available the creation of .NET Core 2 projects.
I tried to create a Docker solution with the new kid on the block.
Currently it seems that with Yeoman there are still no support for .NET Core 2, the available templates at the moment are only for .NET Core 1:

So i tried to create first the project with Visual Studio 2017:

I created a new Core Web App MVC named aspnetapp,

without enabling the native Microsoft support for Docker; launching the Web App it worked without issues:

Then i added a Dockerfile in the project root with this content, following the official page:

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

And a .dockerfile in order to make the build context as small as possible

bin\
obj\

at this point from command prompt in the directory where is Dockerfile

docker build -t aspnetapp .

and then with

docker run -d -p 8080:80 --name myapp aspnetapp

the site this time runs from the container:

and we have the new image:

D:\work\MyDotNetCoreApp\aspnetapp>docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
aspnetapp                     latest              a7ed19cfc58e        8 hours ago         283MB

Categories: .NET Core, Docker, Vs2017