Date

Failed to Create Container with Error: ‘The container operating system does not match the host operating system.’

Issue

Failed to create container with error,The container operating system does not match the host operating system.’

Symptoms

  • Failed to crate a Windows Container with error, “Failed to create container with error,The container operating system does not match the host operating system.'”
  • While installing Windows Features in Container, installation fails with error: “The request to add or remove feature on the specified server failed. The operation cannot be completed, because the server that you have specified requires a restartStatus: 0x800f0922
  • Created a Docker file for Windows Server Core Image with ARG to enable Internet Information Service. Used Docker Build command to create Windows Serve Core 2016 with IIS. Image build failed while enabling IIS with error: “The request to add or remove feature on the specified server failed. The operation cannot be completed, because the server that you have specified requires a restart
   
IMAGE: Add-WindowsFeature Failed with Error-0x800f0922

Cause

Patch update level of the Container Image (Base Image) and Windows Container Host are different.

Solution

Update Windows Container Host to the latest Build (Patch Level)

Recommend to have Container image and Windows Container Host (base) image at the same patch level.

Steps to reproduce the issue:

  1. Pull Container Image for Swarm Visualizer: stefanscherer/visualizer-windows

PS C:\Users\JimmyCater\app> docker pull stefanscherer/visualizer-windows

  •   Create Container with image, ‘stefanscherer/visualizer-windows’

docker run -it -d --name=Sample stefanscherer/visualizer-windows

Failed with error message, ‘The container operating system does not match the host operating system.’

C:\Program Files\Docker\docker.exe: Error response from daemon: hcsshim::CreateComputeSystem b66214cb581dc2ab21154761eef11326d72fbca6a97ce6a9eb1e2b7d58a8e31e: The container operating system  does not match the host operating system.

  •   Checked Dockerfile for Container Image: stefanscherer/visualizer-windows

—-

FROM stefanscherer/node-windows:6.9.2-nano

WORKDIR /app

—–

Base Images is stefanscherer/node-windows:6.9.2-nano. NodeJS is required to run Visualizer Website

  • Browsed to the Docker Hub for Container Image: ‘stefanscherer/node-windows’
  • Verified Docker File for latest NodeJS Image

Compatible image: mcr.microsoft.com/windows/nanoserver:1809

—-

ARG core=mcr.microsoft.com/windows/servercore:ltsc2019

ARG target=mcr.microsoft.com/windows/nanoserver:1809

FROM $core as download

—-

  • Copy Complete Docker Swarm Visualizer files to C:\Users\JimmyCater\docker-swarm-visualizer-master

<<docker-swarm-visualizer-master.zip>>

  • Edit Docker File, ‘Dockerfile.windows’ with following lines:

FROM stefanscherer/node-windows:latest

  • Rename ‘Dockerfile.windows’ to ‘Dockerfile’ (Remove other Docker File to Desktop)
  • Run following command in the PowerShell:

docker build -t visualizer:latest . 

1. New Docker Images will be created:

docker images 

REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE

visualizer                                 latest              412ba112590e        12 minutes ago      462MB

2. Set DOCKER_HOST environment variable to listen on Port: 2375 in running the container. Create a Container name: visualizer  with docker images: visualizer:latest

$ip=(Get-NetIPAddress -AddressFamily IPv4 ` 

>>    | Where-Object -FilterScript { $_.InterfaceAlias -Eq "vEthernet (HNS Internal NIC)" } `

>>    ).IPAddress 

docker run -d -p 8080:8080 -e DOCKER_HOST=${ip}:2375 --name=visualizer visualizer:latest

3. Filter the Container for .NetworkSettings.Networks.nat.IPAddres

docker inspect -f    "{{ .NetworkSettings.Networks.nat.IPAddress }}" visualizer 

172.28.x.x

4. Open Browser and type following as URL: 172.28.xx.xx:8080 to access web-application

IMAGE: Web Application

AZmachina

Knowledge Shared = Knowledge2

We have created AZmachina blog to share our knowledge on Docker & Container and Kubernetes on Windows Servers with curious and enthusiastic novice learner. We hope that this will help them to take a swim in this vast ocean of Window Containers and Kubernetes

Happy Learning !
Recent Posts
Categories
Archives
Sumeet Kumar

Sumeet Kumar

I am Windows Core Engineer with 7+ years of experience in Windows Hyper-v, Failover Cluster, Windows Storage, Volume Shadow Copy (VSS), Docker & Containers on Windows Servers, Backup & Recovery, VMware vSphere EXSi & vCenter Server

RELATED

Articles

Leave a Reply

Your email address will not be published. Required fields are marked *