Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to create folder inside docker container

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading