I have created a python link from python3, but it is not saved when I log in to container image. Why?
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y libxml2-dev xmlsec1
RUN apt-get install -y python3-pip python3-dev
RUN cd /usr/local/bin
RUN ln -s /usr/bin/python3 python
RUN pip3 --no-cache-dir install --upgrade pip
RUN rm -rf /var/lib/apt/lists/*
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD python3 app.py
CodePudding user response:
Command RUN
launches a new shell every time. As a result, working directory is not preserved between dockerfile steps, so
RUN cd /usr/local/bin
won't affect the following ln
command. You can combine both commands in one step:
RUN cd /usr/local/bin && ln -s /usr/bin/python3 python
Alternatively, use WORKDIR
or provide the full link path to ln
.