1

Im trying to build a docker image and get:

ERROR: failed to solve: cannot replace to directory /home/user/.local/share/docker/overlay2/4x9idkq31iucxi4u45xhi7wqp/merged/bin with file

This happens when i am trying to copy.

COPY --from=builder / /

The same docker file build and run on my machine but on another machine it doesn't.

My machines docker version: Docker version 20.10.12, build e91ed57 Other machine: Docker version 23.0.6, build ef23cbc

Any idea on how to fix this issue. Thank you.

I pruned the docker system and restarted the docker engine. Tried rebuilding but problem persisted.

EDIT: Adding a snipper of the dockerfile contents to reproduce the problem:

FROM ubuntu:focal as base
FROM base as builder

# Install dependencies

RUN DEBIAN_FRONTEND=export LANG=en_US.UTF-8
# RUN DEBIAN_FRONTEND=locale-gen "en_US.UTF-8"
RUN DEBIAN_FRONTEND=export PATH="$HOME/.local/bin:${PATH}"
# RUN DEBIAN_FRONTEND=set -eux

RUN rm -rf /var/lib/apt/lists/*

FROM python:3.8.3-slim

RUN mkdir /install
WORKDIR /install
RUN apt-get update && \
    apt-get install build-essential libffi-dev -y && \
    python -m ensurepip && \
    pip install --upgrade pip

COPY requirements.txt ./

RUN pip install setuptools wheel && python -m pip install --no-cache-dir --upgrade pip setuptools
ENV PYTHONPATH /usr/local/lib/python3.8/site-packages
RUN pip install -r requirements.txt

RUN apt-get update && apt-get upgrade -y

COPY --from=builder / /

3
  • Do you have a minimal reproducible example? That COPY command is trying to overwrite the entire container filesystem, and that's unlikely to work well; you can run into hard-to-debug issues around shared libraries and other sorts of conflicts. Commented May 10, 2023 at 13:03
  • I have edited my initial post and it now includes a snippet that reproduces the error. Commented May 24, 2023 at 11:50
  • Trying to copy the entire filesystem from one image stage to another doesn't seem likely to end well: things like the system binaries in /bin and the shared libraries in /usr/lib will get overwritten with possibly-incompatible things. What do you want this line to actually do? Commented May 24, 2023 at 13:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.