Friday, October 28, 2022

[SOLVED] Dockerd can't perform `apt-get update` when building image on windows

Issue

I'm trying to run docker compose stack using Docker Engine Windows service, installed with dockerd.exe --register-service. When I run docker compose up I get the following log:

Step 4/14 : RUN apt-get update
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
 ---> Running in 7e50524784b1
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8184 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [186 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [6344 B]
Fetched 8585 kB in 15s (578 kB/s)
Reading package lists...
1 error occurred:
        * Status: The command '/bin/sh -c apt-get update' returned a non-zero code: 4294967295: failed to shutdown container: container 7e50524784b12e1c4f94537b3a700ae61eb35bdc597b0d277c750b203dae97e4 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 7e50524784b12e1c4f94537b3a700ae61eb35bdc597b0d277c750b203dae97e4 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110), Code: 4294967295

Dockerfile:

# syntax=docker/dockerfile:1
FROM python:3.10-bullseye
WORKDIR /app
COPY Pipfile Pipfile 
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6  -y
RUN pip install pipenv 
RUN pipenv install
COPY . .
ENV STREAMLIT_BROWSER_GATHER_USER_STATS=false
ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=2000
ENV STREAMLIT_SERVER_RUN_ON_SAVE=true
ENV STREAMLIT_SERVER_HEADLESS=true
CMD ["pipenv", "run", "streamlit", "run", "src/main.py"]
EXPOSE 8501

docker-compose.yml:

version: "1.27.0+"

services:
  app:
    build: .
    ports:
      - "8501"
    platform: linux/amd64
    volumes:
      - .:/app

Also before getting these errors, I received this, which I solved by running dockerd -experimental. And error that it can't find linux containers, which I solved by this.


Solution

I believe your problem is that dockerd on Windows will try to run Windows containers, not Linux. When using Docker desktop, it changes the context to use WSL 2 for Linux containers and HCSv1 for Windows containers. I'm not sure if you can set up dockerd directly. What is the environment? Is it a Windows client or Server?



Answered By - Vinicius Apolinario
Answer Checked By - Gilberto Lyons (WPSolving Admin)