3

I get this error when I try to build my Dockerfile. How can I fix this?

failed to compute cache key: "/Pipfile.lock" not found: not found

# Pull base image
FROM python:3.9

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
WORKDIR /code
# Install dependencies

COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system

# Copy project
COPY . /code/
gzm
  • 73
  • 6
  • 1
    Do you have pipfile.lock in your local project root? Would be helpful to see a screenshot of your project structure. My guess is you need to run pipenv lock before building the image to generate pipfile.lock – ENDEESA Feb 21 '21 at 05:03

3 Answers3

1

Your Dockerfile has to be inside your hello dir

I got the same problem because i have my docker file inside my Desktop so i moved my Dockerfile to my hello Dir(ie, your project dir) and it works!

  • My dockerfile is inside the project dir but my problem does not resolve, https://stackoverflow.com/q/67391438/1539100 – sorosh_sabz May 04 '21 at 20:06
0
FROM python:3.9.6
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
Copy . /code/
  • 1
    While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Kevin M. Mansour Aug 24 '21 at 00:59
0

I have the same problem. But I have solved just now.

What I want to say, please, close the dockerfile and reopen it, make sure the contents and the repairement again. Moreover, to make sure that the Dockerfile is on the hello directory.I think you have mistaken something about the updates.

I think your file on the question is correct. Another possibility is , python:3.9.x, not 'python:3.9' (It might be...)

You should move the Dockerfile to hello directory, move your current directory on the command prompt. And retry it, please.

In my case, I editted it, following the designation of my book, but I failed to do the command. I got the same error.

But I closed it once, and reopened it, found my edit is cancelled with some reason.

(Appendix) I have mistook some points.

#Pull base image
FROM python:3.10.4 # wrong→ I have forgotten :

#Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

#Set work directory
WORKDIR /code  # wrong→ I made a blank. / code

# Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system # wrong→ same. -- system

# Copy project
COPY . /code/

I editted Dockerfile over and over again, but the command failed each time, and threw the same error.

Because the revision is not adopted, the errors occured. I don't know the reason, though.

But I have run into error in the case of docker-compose.yml: '3.10.4'

ERROR: Version "3.10.4" in ".\docker-compose.yml" is invalid.

'3.10' went well.

Haru
  • 1,884
  • 2
  • 12
  • 30