Search code examples
dockerdockerfile

Dockerfile build "Can't add file to tar" unless I delete unrelated directory


I'm trying to build a Docker container with a Dockerfile, but it keeps erroring out unless I delete an entirely unrelated directory from my file system.

Based on my Dockerfile contents and placement, it should never have anything to do with the directory C:\\src\\bling\\blingDemo\\Models\\SemanticDocument, however this is what the error is related to. Deleting this directory resolves the error. Why is this happening?

Here are my Dockerfile contents:

# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022

# Copy build files into the container.
COPY SDWebServer/ Users/Administrator/Downloads/Models/SDWebServer/

# Install chocolatey.
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# Install Python version 3.9
RUN choco install -y python3 --version 3.9

# Install requirements.txt
RUN pip install -r Users/Administrator/Downloads/Models/SDWebServer/requirements.txt

Here is my error message:

(base) PS C:\src\bling\blingDemo\Models>
time="2023-12-08T17:40:03-08:00" level=error msg="Can't add file \\\\?
\\C:\\src\\bling\\blingDemo\\Models\\SemanticDocument\\packages\\System.Xml.XDocument.4.3.0\\ref\\wp80 
to tar: archive/tar: missed writing 1128967 bytes"

This is what my file structure looks like: enter image description here


Solution

  • New file Models\.dockerignore and with content:

    SemanticDocument
    

    to tell docker not to include directory SemanticDocument into build context.