Denis Steinman
Denis Steinman

Reputation: 7799

Docker fails on build for any command inside container

I've installed Docker on Windows Server 2019 according to this manual but when I try to build my image it fails with errors:

Step 5/13 : RUN python3 -m venv /opt/venv
 ---> [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 6b034a5cbe59
The command '/bin/sh -c python3 -m venv /opt/venv' returned a non-zero code: 4294967295: failed to shutdown container: container 6b034a5cbe59b5aae61936320a216306c1722c2cccf63a93069ed5897940c290 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 6b034a5cbe59b5aae61936320a216306c1722c2cccf63a93069ed5897940c290 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)
ERROR: Service 'server' failed to build : Build failed

Here is my Dockerfile:

FROM python:3.8-slim-buster
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements/ requirements/
RUN python3 -m venv /opt/venv
RUN . ./opt/venv
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir --upgrade setuptools
RUN pip install --no-cache-dir -r requirements/common.txt
RUN pip install --no-cache-dir psycopg2-binary
COPY . .
RUN ["chmod", "+x", "/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

docker-compose.yml:

version: '3.9'
services:
  server:
    build:
        context: .
        dockerfile: Dockerfile
    environment:
      - "SQLALCHEMY_DATABASE_URI=<DB_CONNECTION_STR>"
      - "RAW_DATA_DIR=/app/mydrive"
    restart: "always"
    volumes:
      - ${CONFIG_PATH}\companyLogo.png:/app/files/branding/companyLogo.png
      - mydrive:/app/mydrive
    networks:
      - internal
    ports:
      - '80:80'
    command: "server"
volumes:
  mydrive:
    driver: local
    driver_opts:
      type: cifs
      o: 'username=<USERNAME>,password=<PASSWORD>,domain=<DOMAIN>,uid=5000,gid=6000'
      device: '<LINK_TO_MY_SERVER>'
networks:
  internal:

As it shown above there is a simple Docker image for Flask, and if I will run a pure python:3.8-slim-buster image and run all these commands manually then all works. However, docker build . and docker-compose build fail. I tried to google the error and error code but there is a nothing useful.

Why does it happen? How to fix it?

Upvotes: 0

Views: 631

Answers (1)

nunohpinheiro
nunohpinheiro

Reputation: 2269

I believe that you will need to use a Python image for Windows Server, as suggested here.

The official Docker images with Python over Windows are listed in the Docker Hub, marked with windowsservercore.

Upvotes: 1

Related Questions