#Windows10 – How to solve “#docker daemon is not running”. Extreme solutions like restart windows won’t work! 馃檧馃檧馃檧

Buy Me A Coffee

Hi !

Time to share a weird experience on Windows 10 and Docker. Sometimes, usually after some Windows 10 update or even after a software installation, docker stop responding.

An typical error may look like this.

error during connect: This error may indicate that the docker daemon is not running.: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile.amd64&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=noToday.azurecr.io%2FU%3A0.0.88-amd64&target=&ulimits=null&version=1: open //./pipe/docker_engine: The system cannot find the file specified.

From Visual Studio Code we get:

And it’s very weird. When I check the Docker desktop app, it’s stuck in the the STARTING state.

docker windows 10 for ever in starting mode

I can restart the docker desktop app, and I will still have the issue. As I said, weird.

I’m a handy man, so I decided to restart the docker service. Just 2 commands:

Net stop com.docker.service
Net start com.docker.service

However, this does not solve the problem. And sometimes, even restarting Windows won’t fix the problem.

After some time, I found the root cause:

Somehow WSL was set to version 1 instead of version 2.

I’m not sure why, however the solution is super easy. Just run a command to set WSL to version 2 and then restart docker service.

wsl --set-default-version 2
Net stop com.docker.service
Net start com.docker.service

If you are a visual person, this may look like this:

docker windows 10 set WSL2 as current version

Important: you need to run these commands with Administrator privileges. So in a Windows Terminal world, this may also look like this. Right click on the Windows Terminal App, and click on “Run as administrator”.

Happy coding!

Greetings

El Bruno



驴Con ganas de ponerte al d铆a?

En Lemoncode te ofrecemos formaci贸n online impartida por profesionales que se baten el cobre en consultor铆a:

#CustomVision – Analizando im谩genes con PostMan con un proyecto de #CustomVision en un #Docker Container

Buenas !

El post de hoy es uno simple, y que tengo que apuntar para el futuro:

Utilizar PostMan para realizar una petici贸n HTTP POST para analizar una imagen con un proyecto de Custom Vision alojado en un Docker container.

En mis post anteriores escrib铆 sobre como crear y exportar un proyecto en CustomVision.ai; y tambi茅n sobre como ejecutar el mismo en un contenedor Docker,聽 y analizar una imagen desde una aplicaci贸n de Consola .NetCore.

En el post de hoy utilizare el mismo entorno, y analizare una imagen utilizando una de las herramientas mas populares entre los web developers: Postman.

Vamos a ello. Creamos una sesi贸n en Postman y definimos la URL y el tipo POST de http request. Para enviar una imagen, debemos agregar un nuevo header para definir el Content-Type como image/jpg.

01 postman header image jpg

La imagen sera enviada en modo binary content en el body de la petici贸n. Selecciono la imagen con la que realizare la prueba.

02 postman body raw file

Una vez realizada la petici贸n, podemos ver el resultado en formato JSON, con las entidades detectadas y sus frames.

03 postman json results

Adicionalmente, podemos exportar esta sesi贸n en c贸digo en diferentes lenguajes. Por ejemplo: C#, Java, Go o Python.

04 postman generate code

El c贸digo en python de ejemplo:

import http.client
conn = http.client.HTTPConnection("127,0,0,1")
headers = {
'Content-Type': "image/jpg",
'cache-control': "no-cache",
'Postman-Token': "847d04a8-0d05-4637-a056-7dbbdf10009b"
}
conn.request("POST", "image", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Happy coding!

Saludos @ Burlington

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Analyzing images using PostMan from a #CustomVision project hosted in a #Docker Container

Hi !

Today’s post is a simple one that I’ll use for sure in the future:

How to make an HTTP Post Request using Postman to analyze an image using a Custom Vision project hosted in a docker container.

In my previous posts I share the necessary steps to export a CustomVision.ai project and run the project in docker. I also show how to send images for analysis from a .NetCore Console App.

Today I’ll use another popular tool to perform the Http call to the docker container: Postman. This is one of the most popular tools in the web development world, and for sure is a good one if even myself knows how to use it!

So, once we have our session in Postman the container URL and POST are very straightforward. We are going to send an image, so we need to add a header with the Content-Type as image/jpg.

01 postman header image jpg

The image will be sent as binary content in the body. With 2 clicks we can select the file to use for testing.

02 postman body raw file

And finally, the result is an amazing JSON that we can analyze and see how our model performs

03 postman json results

And as a bonus, once we have a test defined in PostMan, we can easily export the test as code in different programming languages like C#, Java, Go or Python.

04 postman generate code

Here is a sample of the generated python code

import http.client
conn = http.client.HTTPConnection("127,0,0,1")
headers = {
'Content-Type': "image/jpg",
'cache-control': "no-cache",
'Postman-Token': "847d04a8-0d05-4637-a056-7dbbdf10009b"
}
conn.request("POST", "image", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Analizando im谩genes en una Console App utilizando un proyecto de #CustomVision en #Docker Container

Buenas !

Este es un post especial, ya que es el 1ro que escribo completamente desde mi . Estoy seguro que聽 Javier (@jsuarezruiz), Yeray (@JosueYeray), Braulio (@braulio_sl), Luis, Sara, Roberto y otros mac users estar铆an orgullosos de mi 馃榾

Basado en el post anterior, he compilado y ejecutado mi proyecto Custom Vision Marvel en Docker para Mac. La experiencia es buen铆sima, y bash tambi茅n es una novedad interesante!

docker build -t elbruno/cvmarvel:3.0 .

01 doker build on mac

El siguiente paso es obtener en ID y ejecutar la misma.

03 docker list images and run image

El paso final es utilizar CURL para hacer una petici贸n HTTP Post con una imagen para analizar. Es muy simple, salvo que me tomo unos minutos y unas b煤squedas en bing el darme cuenta que hay utilizar el prefijo @ en la llamada desde la consola! Iron Fist detected !

curl -X POST http://127.0.0.1:8080/image -F imageData=@img1.jpg聽

05 docker bash ls image analyzed and source image.png

Ok, el entorno de pruebas con Docker esta funcionando, as铆 que ahora es momento de utilizar Visual Studio for Mac. En realidad la app es una .Net Core Console App, que podr铆a crear en Visual Studio Code, pero esta es la excusa perfecta para comenzar a conocer Visual Studio for Mac.

Mi codigo de pruebas esta en Azure DevOps, as铆 que despu茅s de sincronizar los repositorios, ya pude crear un nuevo proyecto a mi soluci贸n.

06 new netcore project in visual studio for mac

Un par de lineas de c贸digo C# en la console app y ya pude realizar el an谩lisis de la imagen utilizando el contenedor con el proyecto de Custom Vision

07 console app in vs for mac detected image

El c贸digo es muy simple:

using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace CustomVisionMarvelConsoleDocker01
{
static class Program
{
static void Main()
{
MakePredictionRequest("IMG01.jpg").Wait();
Console.ReadLine();
}
static async Task MakePredictionRequest(string imageFilePath)
{
var client = new HttpClient();
var url = "http://127.0.0.1:8080/image";
var byteData = GetImageAsByteArray(imageFilePath);
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = await client.PostAsync(url, content);
var jsonResponse = await response.Content.ReadAsStringAsync();
var prettyJson = JToken.Parse(jsonResponse).ToString(Formatting.Indented);
Console.WriteLine(prettyJson);
}
}
static byte[] GetImageAsByteArray(string imageFilePath)
{
var fileStream = new FileStream(imageFilePath, FileMode.Open, FileAccess.Read);
var binaryReader = new BinaryReader(fileStream);
return binaryReader.ReadBytes((int)fileStream.Length);
}
}
}

Happy coding!

Saludos @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Analyzing images in a Console App using a #CustomVision project in a #Docker Container

Hi !

This is a special post. It’s the 1st one I write completely in my MacBook, so I’m sure that Javier (@jsuarezruiz), Yeray (@JosueYeray), Braulio (@braulio_sl), Luis, Sara, Roberto and other mac users will be proud of me 馃榾

So, I build and run my Custom Vision Marvel project in Docker for Mac. Smooth build and also a fast one!

docker build -t elbruno/cvmarvel:3.0 .

01 doker build on mac

Then get the image id and run the image

03 docker list images and run image

Final step is to play around with curl in bash to post the image (the file name with @ prefix took me some bing searches). Iron Fist detected !

curl -X POST http://127.0.0.1:8080/image -F imageData=@img1.jpg聽

05 docker bash ls image analyzed and source image.png

Ok, the environment is working, so it’s time to create a .NetCore Console App to test this using amazing C# code. I have all my code in Azure Dev Ops, so I sync my repo and聽 added a new project in my current solution

06 new netcore project in visual studio for mac

Some C# lines in my console app and I was able to analyze a local picture using the Custom Vision Model in a container

07 console app in vs for mac detected image

The source code is very simple

using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace CustomVisionMarvelConsoleDocker01
{
static class Program
{
static void Main()
{
MakePredictionRequest("IMG01.jpg").Wait();
Console.ReadLine();
}
static async Task MakePredictionRequest(string imageFilePath)
{
var client = new HttpClient();
var url = "http://127.0.0.1:8080/image";
var byteData = GetImageAsByteArray(imageFilePath);
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = await client.PostAsync(url, content);
var jsonResponse = await response.Content.ReadAsStringAsync();
var prettyJson = JToken.Parse(jsonResponse).ToString(Formatting.Indented);
Console.WriteLine(prettyJson);
}
}
static byte[] GetImageAsByteArray(string imageFilePath)
{
var fileStream = new FileStream(imageFilePath, FileMode.Open, FileAccess.Read);
var binaryReader = new BinaryReader(fileStream);
return binaryReader.ReadBytes((int)fileStream.Length);
}
}
}

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Utilizando un proyecto Custom Vision en un #Docker Container local

Buenas !

Ahora que ya tengo en funcionamiento Docker en Windows 10 es tiempo de exportar un proyecto de CustomVision y ejecutarlo dentro de un container.

Cuando exportamos hay 2 version disponibles: Linux or Windows

00 CV exported to docker

En mi caso no pude compilar la versi贸n de Windows, asi que trabajare con la versi贸n de Linux. El zip que descargamos tiene varios archivos, como el DockerFile con la definici贸n del container, el modelo de ML, los archivos python para leer y realizar an谩lisis de imagenes y varios archivos mas.

FROM python:3.5

ADD app /app

RUN pip install –upgrade pip
RUN pip install -r /app/requirements.txt

# Expose the port
EXPOSE 80

# Set the working directory
WORKDIR /app

# Run the flask server for the endpoints
CMD python app.py

Esta imagen utiliza Python 3.5, y el comando para compilar la imagen es

docker build -t elbruno/cvmarvel:3.0 .

05 CV docker build image in windows

Un par de segundos despu茅s, la imagen esta compilada y disponible en la store local

docker image ls

07 Docker local images

Ahora que se mi IMAGE ID, ya puedo iniciar la ejecuci贸n de la imagen. En este caso, utilizare el puerto 8080

docker run -p 127.0.0.1:8080:80 -d ddd1623ee694

En este ejemplo utilizare PowerShell y el comando Invoke-WebRequest para realizar una petici贸n HTTP Post con una imagen

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -ContentType ‘image/jpg’

06 CV running and testing an image on docker

El resultado detecta una imagen, sin embargo no tengo todo el resultado Json disponible. Para esto, agregare un archivo de salida en la petici贸n para guardar en el mismo el resultado del an谩lisis de la imagen. Ahora ya puedo ver que detecta Iron Fist y a Venom!

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -Outfile “D:\docker\result.json” -ContentType ‘image/jpg’

08 docker results in visual studio code

Happy coding!

Greetings @ Burlington

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Running a Custom Vision project in a local #Docker Container

Hi !

So now that I have Docker running in Windows 10, it’s time to use a Custom Vision model in Windows hosted in Docker container.

There are 2 version available to export from CustomVision.ai for each one the projects: Linux or Windows

00 CV exported to docker

I could not sucessfully built the Windows version, so I’ll work with the Linux one. Once exported the zip file have a set of python files to tun the model, the model file (model.pb) and a Dockerfile to build the docker image.

FROM python:3.5

ADD app /app

RUN pip install –upgrade pip
RUN pip install -r /app/requirements.txt

# Expose the port
EXPOSE 80

# Set the working directory
WORKDIR /app

# Run the flask server for the endpoints
CMD python app.py

The image uses Python 3.5, and the build command is as simple as

docker build -t elbruno/cvmarvel:3.0 .

05 CV docker build image in windows

After a couple of seconds, the image is build in the local store

docker image ls

07 Docker local images

Once I have my IMAGE ID, it’s time to start the image. For this demo, I’ll use the port 8080

docker run -p 127.0.0.1:8080:80 -d ddd1623ee694

And then I can submit an image using Invoke-WebRequest and view the results directly in PowerShell

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -ContentType ‘image/jpg’

06 CV running and testing an image on docker

In order to get the complete output of the POST request, I must add an OutFile into the PowerShell comand. And in the complete output we can see some Iron Fist and Venom results!

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -Outfile “D:\docker\result.json” -ContentType ‘image/jpg’

08 docker results in visual studio code

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#Windows10 – Problemas al instalar #docker en Windows 10 Home, necesitas Pro o Enterprise

Buenas !

Voy a poner on hold mis posts sobre Custom Vision para agregar un peque帽o ayuda memoria para mi:

No instales Windows 10 Home si piensas utilizar Docker!

Hace poco instale un nuevo entorno de desarrollo y al momento de instalar Docker Desktop me encontr茅 con el siguiente mensaje

Docker Desktop requires Windows 10 Pro or Enterprise version 14393 to run.

cant install docker 2.0.0.2 on win10 1903 18329

La primera idea que vino a mi mente era alguna incompatibilidad entre Windows Insider y Docker, y luego de un par de b煤squedas en Bing me di cuenta que no es posible instalar Docker Desktop en Windows 10 Home edition.

win 10 home edition

Por suerte, el upgrade de Windows 10 Home a Pro es bastante simple. Busque en mis MSDN Product Keys una licencia valida de Windows 10 Pro y actualice mi entorno de desarrollo

upgrading windows

Happy coding!

Saludos @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#Windows10 – Can’t install #docker on Windows 10 Home, need Pro or Enterprise

Hi !

I hold my series of posts on聽 Custom Vision to add another brain reminder, this one is

Do not install Windows 10 Home if you are going to use Docker!

I recently installed a new dev environment, and when I was going to install Docker Desktop I found this amazing message

Docker Desktop requires Windows 10 Pro or Enterprise version 14393 to run.

cant install docker 2.0.0.2 on win10 1903 18329

I initially think that this was related to Windows Insider build, and after a quick bing search I realized that you can’t install docker desktop on Windows 10 Home edition.

win 10 home edition

So, it was time to go to my MSDN Product Keys and find a Windows 10 Pro activation key to upgrade my dev environment

upgrading windows

2 clicks later, it was done and I was able to continue my Docker journey!

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series