Questions & Answers

Windows 10 Docker - Entrypoint not found

On my work there is a docker project with all backend setup. The code of dockerfile:

FROM python:3.9.6-alpine

# Установка локальных переменных

RUN mkdir -p /usr/src/freedom
WORKDIR /usr/src/freedom

# Установка зависимостей для Django
RUN apk update \
    && apk add postgresql \
    && apk add postgresql-dev \
    && apk add gcc libc-dev make git libffi-dev openssl-dev python3-dev libxml2-dev libxslt-dev \
    && apk add jpeg-dev zlib-dev libjpeg libffi-dev
#     && pip install Pillow \
#     && apk del build-deps


CMD python3 --version
CMD . env/bin/activate
COPY ./requirements.txt ./requirements.txt

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY . .

# run
ENTRYPOINT ["/usr/src/freedom/"]

When running the project with docker-compose up --build (right after clonning, no shenanigans) on Linux everything works fine. It finds its fine) its okay. When running from windows entrypoint dont run.

  • Running entrypoint from a global path like "C:/abc/abc/.."

Please help

I tried:

  • Removing ENTRYPOINT and running it as CMD
  • Adding entry point to /usr/src/freedom on my C: folder
  • Changing paths
2023-01-21 23:52:03
Your container is Alpine, not Windows. When you use an entrypoint the path you give is from inside the machine
2023-01-21 23:52:03
Why would you change a path in your linux-based container to a windows-like path?
2023-01-21 23:52:03
@deprirscher I really dont know man, I never worked with linux :P Can you help me to set it up?
2023-01-21 23:52:03
@PedroRodrigues Hey, what do I need to do right now to fix it? This path works on my ubuntu vm
2023-01-21 23:52:03
@ColdDarkness Are you sure you need to change anything? The machine you are using shouldn't really matter. Also, having more than one CMD instruction is useless, you can only use one, which will be the latest one (
2023-01-21 23:52:03
@PedroRodrigues it doesnt work. isnt found like that and I don't know why
2023-01-21 23:52:03
Where is that file located? Is it where you executed docker-compose up --build? Like, if you use ls in the same place you execute that command, does it have the entrypoint.shfile?
2023-01-21 23:52:03
2023-01-21 23:52:03
Hmm... What does it show if you use RUN ls -la between the COPY and ENTRYPOINT instructions?
2023-01-21 23:52:03
Answers(1) :

One option you have is to call the shell and execute the file, as if: ENTRYPOINT["/bin/sh", "-c", "sh /usr/src/freedom/"]

But in the end I think the best solution will be to simply use a single CMD instruction, like: CMD["/usr/src/freedom/"] (with this I mean you should remove all the CMD and ENTRYPOINT instructions you currently have and use this one.)

You can check the difference between CMD and ENTRYPOINT in the documentation and this SoF post:

Also, as stated in the documentation, having two CMD commands is useless since the latest one is the one that will be applied.