When building a Docker file, I get the error
"/bin/sh: 1: apt-get: not found"
docker file:
FROM python:3.8
FROM ubuntu:20.04
ENV PATH="/env/bin/activate"
RUN apt-get update -y && apt-get upgrade -y
WORKDIR /var/www/html/
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["python", "manage.py"]
CodePudding user response:
You are setting the
PATH
to/env/bin/activate
and that is then the only place whereapt-get
is searched for. There is no need to activate a virtual env inside the container, just get rid of that line.pip
can install the packages inrequirements.txt
to the "system" Python without issues.You cannot layer 2 images like you are attempting to do, with multiple FROM statements. Just use
FROM python:3.8
and drop the ubuntu. MultipleFROM
statements are used in multi-stage builds where you have intermediate images which produce artifacts that are copied to the final image.
So just do:
FROM python:3.8
RUN apt-get update -y && apt-get upgrade -y
WORKDIR /var/www/html/
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["python", "manage.py"]
.. although why you would put Python code in /var/www/html beats me. Probably you don't.