I'm trying to create a folder(/data/connect) inside my docker container at location (/usr/local/lib/python2.7/site-packages/ip360da) and for that, I have mentioned that step inside my dockerfile (RUN mkdir -p /usr/local/lib/python2.7/site-packages/ip360da/data/connect) but somehow this particular folder is not getting created inside this directly here is my dockerfile.
FROM python:2.7.18 as build
WORKDIR /build
COPY config/requirements.txt \
config/test.json \
builddir/.netrc \
./
RUN mkdir -p /usr/local/lib/python2.7/site-packages/ip360da/data/connect
COPY config/config.json /usr/local/lib/python2.7/site-packages/ip360da/data/connect
##############################################################
FROM python:2.7.18-slim
WORKDIR /app
COPY --from=build /build /app
RUN mv .netrc ~ && \
apt-get update && \
apt-get upgrade --assume-yes && \
# Used by Pipeline to differentiate from manually installed packages
apt list --installed >/tmp/preinstalled-packages 2>/dev/null && \
apt-get clean && \
groupadd --gid 2000 tripwire && \
useradd --system --uid 2000 --gid tripwire tripwire
RUN pip install -r /app/requirements.txt
COPY scripts/daemon.py /usr/local/lib/python2.7/site-packages/ip360da/utils
COPY scripts/mock.py /usr/local/lib/python2.7/site-packages/ip360da/vne
USER root:root
ENTRYPOINT sleep infinity
CodePudding user response:
You create the directory in the build stage of the build. That doesn't end up in the final image. Only things after the last FROM statement in the Dockerfile end up in the image.
So instead of
RUN mkdir -p /usr/local/lib/python2.7/site-packages/ip360da/data/connect
COPY config/config.json /usr/local/lib/python2.7/site-packages/ip360da/data/connect
##############################################################
FROM python:2.7.18-slim
You should do
##############################################################
FROM python:2.7.18-slim
RUN mkdir -p /usr/local/lib/python2.7/site-packages/ip360da/data/connect
COPY config/config.json /usr/local/lib/python2.7/site-packages/ip360da/data/connect