IMPORTANT NOTE : .NET Core Container Images now Published to Microsoft Container Registry

THIS IS AN IMPORTANT ANNOUNCEMENT: Microsoft is now publishing .NET Core container images to Microsoft Container Registry (MCR).

Note that Microsoft will continue to maintain Docker Hub repo pages so that you can discover and learn about .NET Core images. The Docker Hub website URLs you’ve used for Microsoft repos will continue to work, and forward to updated locations on Docker Hub.

Important :

  • Microsoft also made other changes to the images we publish, described in this post.
  • You will need to change FROM statements in Dockerfile files and docker pull commands as a result of these changes. 3.0 references need to be changed now. Most 1.x and 2.x usages can be changed over time. The new tag scheme is decribed in this post and are provided at the microsoft-dotnet-core repo, Microsoft new home on Docker Hub.

For more informations, please refer to this post on .NET Blog.

La présentation de l’aOS Tahiti 2019 est disponible

J’ai eu le plaisir avec Sylver et Patrick de pouvoir organiser un évènement aOS (Azure, Office 365, SharePoint) à Tahiti le 06 Mars 2019 dans les locaux de SF2i Polynésie. Un franc succès ! Merci à eux !

Un évènement qui devrait se reproduire l’année avec une dimension un peu plus importante 😉

Voici ma présentation :



La présentation de l’aOS Nouméa est disponible

J’ai eu le plaisir avec Sylver et Patrick de pouvoir organiser un évènement aOS (Azure, Office 365, SharePoint) à Nouméa le 28 Février 2019 à l’hotel Nouvata. Un franc succès ! Merci à eux !

Un évènement qui devrait se reproduire l’année avec une dimension un peu plus importante 😉

Voici ma présentation :

Install Docker on Windows Server 2016 and bypass SHA256 hash validation error

Installing Windows Container is quite straightforward (follow https://docs.docker.com/install/windows/docker-ee) … except when you have an error message on certain VM (not on every VM) like “Cannot verify the file SHA256. Deleting the file”. After a deep crawl of the web to find a correct way to solve this issue, I found a tons of Github issue answers and blog post that works sometimes but mostly are inaccurate and the package version mentioned is outdated. So I introduce you a method that will keep the process right on board version after version.

Update (07/10/2018) : current version is now 18.03.1-ee-2 (=> https://dockermsft.blob.core.windows.net/dockercontainer/docker-18-03-1-ee-2.zip)

Update (07/16/2018) : Microsoft is playing with manifest (labelling latest binaries as ‘TEST’), so files and SHA256 file hash changed over the night. Some installation issues seems better to handle. Stay tuned.

The quick start page from Microsoft to install Docker on Windows Server 2016 is here, and it’s well written (although not very useful when having installation error) : https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server

Get the right version and Docker install file

To download the correct version of the package, you’ll have to get the manifest and to look for your version to get the right URL :

  1. Download the manifest file containing every package version : Start-BitsTransfer -Source https://dockermsft.blob.core.windows.net/dockercontainer/DockerMsftIndex.json
  2. In the manifest, copy the right URL to the install ZIP file (in my case I need 17.06.0-ce) :

image

Installation

Once you know what you need (in my case version 17-06-0-ce), follow these steps to make it work :

  • Go to the temp folder where everything happen (don’t forget to replace by your current username) : cd C:\Users\<username>\AppData\Local\Temp\DockerMsftProvider\
  • Download Docker package (don’t forget to replace the URL by the one you copy previously) : Start-BitsTransfer -Source https://dockermsft.blob.core.windows.net/dockercontainer/docker-17-06-0-ce.zip -Destination /docker-17-06-0-ce.zip.bak
  • Copy the file to keep a backup (during the process the file is deleted, you won’t have to download it again) : cp docker-17-06-0-ce.zip docker-17-06-0-ce.zip.bak
  • Check the SHA256 Hash : Get-FileHash -Path /docker-17-06-0-ce.zip -Algorithm SHA256
  • Install Docker package : Install-Package -Name docker -ProviderName DockerMsftProvider -Verbose -RequiredVersion 17.06.0-ce
  • Tada ! Things should be OK, so the final step is to restart the computer to make everything work like a charm : Restart-Computer -Force

Le premier Afterworks MS à Koné

La première édition des Afterworks MS en Province Nord se sont déroulés à Koné ce Lundi 07/08. Devant l’engouement des personnes présentes pour ce type d’événement, les Afterworks sur Koné devraient être réitérer avec un contenu plus spécifique (et moins dense) dans une prochaine édition.

Un grand merci à la CCI de Koné pour le prêt de la salle (et pour nous avoir attendu en fin de journée) et pour accompagner ces initiatives communautaires depuis maintenant plus d’un an.

Comme convenu, nous avons pu partager notre expérience et expertise des technologies Office 365, SharePoint 2016, Visual Studio & .NET, Docker et Windows Container.
Si vous avez des questions sur ces technologies, si vous souhaitez savoir comment nous les déployons chez nos clients ou dans nos sociétés, n’hésitez pas à nous contacter.

Speakers : Sylver Schorgen (SF2i) et Julien Chable (NC IT – MVP Office Server et Development)

Les slides des sessions sont disponibles ci-dessous :
• Office 365 : https://fr.slideshare.net/secret/16KvWXBVppVgUG
• Nano Server : https://fr.slideshare.net/…/prsentation-nano-server-ms-afte…
• SharePoint 2016 : https://fr.slideshare.net/…/prsentation-sharepoint-2016-786…
• Visual Studio et .NET Core : https://www.slideshare.net/…/visual-studio-2017-launch-keyn…
• Docker :
https://www.slideshare.net/…/introduction-devops-containari…
https://www.slideshare.net/…/lcosystme-docker-pour-les-dev-…

Image may contain: one or more people, people sitting, table, living room and indoor

Maven Docker build failed with ‘org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375’ on Windows

You can have this kind of error when building a project with Maven and the Docker plugin (by Spotify) :

[INFO] Building image kelios-solutions/annuaire
[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 03:16 min
[INFO] Finished at: 2017-06-29T16:59:30+11:00
[INFO] Final Memory: 32M/78M
[INFO] ————————————————————————
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project annuaire: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.
rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect -> [Help 1]

[ERROR]

On Windows, with Docker for Windows, just check if you have exposed the daemon on port 2375 (in Docker for Windows settings) :

image

And your Maven build should create the Docker image.

Fail to pull Windows Core/Nano Server container images with Docker for Windows ‘unknown blob’

During my last session preparation, I switched Docker for Windows to use Windows containers, to be honest I don’t have use it for some times (my nested virtualized Windows Server 2016 do the job) and I had the following error when downloading the microsoft/nanoserver image : unknow blob

image

The issue may be that your Docker for Windows daemon is not completely switch to Windows container. So execute the following line to switch it : & ‘C:\Program Files\Docker\Docker\DockerCli.exe’ –SwitchDaemon

Then pull your image again and things should work :

image

Docker ASP.NET MVC image creation issue ‘GetFileAttributesEx : The system cannot find the path specified’

When using Visual Studio 2017 and trying to create a Docker image for your ASP.NET web app from the standard microsoft\aspnet image (or another image), you may have the following error message : GetFileAttributesEx bin\Release\PublishOutput : The system cannot find the path specified

image

This error is caused by the .dockerignore file generated by Visual Studio 2017 (more information on .dockerignore file : https://docs.docker.com/engine/reference/builder/#dockerignore-file).

How to solve the issue

  1. Open and edit the .dockerignore file located at the root of your Visual Studio project
  2. Remove the first line with the ‘*’ (this is the guilty line !)
  3. Save the modified .dockerignore file
  4. Re execute your docker build command (ex : docker build –t <your tag> .)

Original Visual Studio 2017 .dockerignore file :

image

The corrected .dockerignore file :

image

Check your web app to know if everything works fine

  1. First, you won’t be able to use the URL http://localhost, you need the IP address of the container. To find it, execute this command in Powershell :
  2. docker inspect -f « {{ .NetworkSettings.Networks.nat.IPAddress }} » ncit_liasse

  3. Open your favorite browser and enter the URL http//<your ip address> to show you web app shining

image

More documentation on the use of this image at https://hub.docker.com/r/microsoft/aspnet/

Useful documentation on how to migrate an ASP.NET MVC application to Docker : https://docs.microsoft.com/en-us/aspnet/mvc/overview/deployment/docker-aspnetmvc

Now enjoy migrating your ASP.NET MVC web apps to Docker containers !

Déployer un projet web ASP.NET Core 1.0 avec Docker sur Windows en 15 minutes

Venant tout juste de passer sous Windows 10 update November 2015 (prérequis pour Docker beta) et souhaitant tester la RC2 fraichement débarquée de .NET Core, je me suis dit qu’un petit post ne serait pas de trop pour prendre les (nouvelles) bonnes habitudes. Aussi voici comment faire court pour créer une application .NET Core :

Installation des prérequis

Pour créer un projet ASP.NET Core :

  • .NET Core SDK (en RC 2 lors de la rédaction de ce post) : https://go.microsoft.com/fwlink/?LinkID=798398
  • NodeJS et son gestionnaire de package NPM : https://nodejs.org
  • Docker pour Windows (si vous êtes sur Windows) ou Docker pour Mac (si vous êtes sur Mac) : https://beta.docker.com/ (l’utilisation de la Beta nécessite l’obtention d’une clef qui arrive au compte goutte en ce moment …). Vous devez également avoir une version de Windows 10 adéquate (avec Hyper-V installé … pourquoi ne l’auriez-vous pas installé d’ailleurs ?!?) et la mise à jour de Novembre 2015.

Création du projet ASP.NET Core

  1. Dans une invite de commande ou dans une console PowerShell :
    1. mkdir coreapp : création d’un répertoire racine pour le projet
    2. cd .\coreapp\
  2. Installation du générateur Yeoman ASP.NET pour créer une application ASP.NET Core (et non juste une application console avec la commande dotnet new)
    1. npm install –g yo : installation de Yeoman
    2. npm install –g generator-aspnet : installation du générateur ASP.NET Core de Yeoman
  3. Création du projet :
    1. yo aspnet : affiche un wizard pour créer un nouveau projet :
      image
  4. Dans le wizard :
    1. Sélectionnez Web Application > Boostrap
    2. Saisissez le nom de l’application
  5. Le générateur va se mettre au travail et récupérer pour vous toutes les dépendances du projet et les placer dans un répertoire du même nom que celui de votre projet.
  6. Nous avons un peu de modification à faire pour rendre notre application compatible avec Docker (et rendre accessible notre application  à l’extérieur du container).
    Ouvrez le fichier Program.cs dans votre éditeur préféré (Visual Studio Code ?)
    Modifiez le contenu pour avoir un contenu similaire à ce qui suit puis enregistrez vos modifications :

    [code language= »csharp » highlight= »1,10,11,12,13,14,18,19″]
    using Microsoft.Extensions.Configuration;


    namespace AppCoreDocker
    {
    public class Program
    {
    public static void Main(string[] args)
    {
    var config = new ConfigurationBuilder()
    .AddEnvironmentVariables("")
    .Build();
    var url = config["ASPNETCORE_URLS"] ?? "http://*:5000";
    var env = config["ASPNETCORE_ENVIRONMENT"] ?? "Development";

    var host = new WebHostBuilder()
    .UseKestrel()
    .UseUrls(url)
    .UseEnvironment(env)
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseStartup&amp;lt;Startup&amp;gt;()
    .Build();

    host.Run();
    }
    }
    }
    [/code]

    Cette modification permet de spécifier à Kestrel d’écouter sur le port 5000 quel que soit l’adresse que nous lui fournissons (merci à Laurent qui m’a évité de perdre du temps). Vous remarquerez la nouveauté liée à la RC 2 de cette configuration.

  7. Une fois le projet générer, les étapes sont les mêmes que pour tout projet :
    1. cd <nom de votre projet>
    2. dotnet restore : restaure les packages Nuget de l’application
    3. dotnet build : compile le projet (se produira si vous faites un run également)
    4. dotnet ef database update : crée la base de données SQLite pour gérer l’authentification (démo uniquement)
    5. dotnet run : lance le serveur Kestrel sur l’URL http://localhost:5000

image

Ouvrez un navigateur web avec l’URL : http://localhost:5000

image

Déploiement avec Docker

Afin de pouvoir lancer votre application dans un container Docker, nous devons créé notre Dickerfile. Le générateur Yeoman vous a déjà généré ce fichier, néanmoins, pour le moment le template de Yeoman n’est pas à jour (notamment l’image de base qui n’est pas la bonne et les actions maintenant avec la commande dotnet au lieu de dnx – cela a été mis à jour dans Github mais pas dans les distributions npm lors de la rédaction de ce post) que vous devrez modifier afin d’avoir un Dockerfile similaire à :

[code]
FROM microsoft/dotnet

ENV ASPNETCORE_ENVIRONMENT= "Production"

COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]

EXPOSE 5000
ENTRYPOINT ["dotnet", "run"]
[/code]

Une fois le fichier modifié, vous pouvez exécuter les commandes suivantes :

  1. docker build –t <votre tag> .
  2. docker run –d –p 5000:5000 <votre tag>

La première commande build crée l’image Docker en installant les dépendances. La commande run exécute un container avec l’image créée précédemment sur le port 5000.

Ouvrez un navigateur web avec l’URL suivante : http://docker:5000 (et non localhost)

image

 

Conclusion

Force est de constater que l’uniformisation de la chaîne de commandes .NET Core et la possibilité de réaliser ses containers Docker dans un environnement Windows (ou Mac) apporte un réel gain de temps et une uniformité des outils quelle que soit l’environnement de développement.

Néanmoins, je ne pourrais que trop vous conseiller de tester vos containers dans un environnement Docker Linux stable et ne pas oublier que pour le moment Docker for Windows est en Beta.