1

I have the following Dockerfile, currently working locally in my device:

FROM python:3.7-slim-buster

WORKDIR /app

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["sh", "-c", "./entrypoint.sh"]

But when I deploy it to Fargate, the container stops before reaching the steady state with:

sh: 1: ./entrypoint.sh: not found

Edit: Adding entrypoint.sh file for clarification:

#!/bin/env sh
# start process, but it should exit once the file is in S3
/app/cat/sitemap_download.py
# Once the process is done, we are good to scale down the service
aws ecs update-service --cluster cluster_name --region eu-west-1 --service service-name --desired-count 0

I have tried modifying ENTRYPOINT to use it as exec form, or with full path but always get the same issue. Any ideas on what am I doing wrong?

Arehandoro
  • 267
  • 1
  • 2
  • 11
  • Not su what do you mean, sorry. The entrypoint.sh is a script in the docker container that runs when the container is launched. If I put the python script instead (ENTRYPOINT/app/cat/sitemap_download.py) the script is found and the container starts, for example. – Arehandoro Oct 06 '20 at 09:49
  • did you try to simply write `ENTRYPOINT ["/app/entrypoint.sh"]`? – Stefano Oct 06 '20 at 09:55
  • Yep, as stated in the post trying full path return the same issue. Works locally but not on Fargate. – Arehandoro Oct 06 '20 at 09:56
  • if it works locally then there's something wrong in how you create and start the container. – Stefano Oct 06 '20 at 09:59
  • How are you running it locally? (I suspect the `VOLUME` line is causing problems and you can just delete it, but I'm not sure it would run locally.) – David Maze Oct 06 '20 at 11:36
  • @Stefano That same container, launched in the exact same way, when having ```ENTRYPOINT ["sh", "-c", "/app/cat/sitemap_download.py"]``` works fine, both locally and in Fargate. But I think you're right, I have changed the entrypoint.sh shebang from ```#!/bin/bash``` to ```#!bin/env sh``` and I get the same error locally now. – Arehandoro Oct 06 '20 at 11:37
  • @DavidMaze I'm running it with docker run. – Arehandoro Oct 06 '20 at 11:38
  • can you provide the full command? – Stefano Oct 06 '20 at 12:17
  • @Stefano ```docker run $container_id``` locally. Via Cloudformation for Fargate. – Arehandoro Oct 06 '20 at 12:47

1 Answers1

1

I've managed to fix it now.

Changing the Dockerfile to look as follows solves the issue:

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["/bin/bash"]
CMD ["./entrypoint.sh"]

I tried this after reading: What is the difference between CMD and ENTRYPOINT in a Dockerfile?

I believe this syntax fixes it because with entrypoint I'm indicating bash to be run at start, and then passing the script as parameter.

Arehandoro
  • 267
  • 1
  • 2
  • 11