1

I started with a functioning Docker clone of a months-old version of an existing project. After integrating all the changes made in the intervening months, the clone runs locally, and builds when docker-compose build is executed. However, when attempting to create a container from the image, docker run... raises the above-mentioned error is thrown, and the container never starts. Commenting out all the newly-added code so that it doesn't run any of the new code doesn't fix it, making me sure that it's an issue with the way it's packaged.

Here are the contents of my Docker files; none of which have changed.

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
WORKDIR /app
COPY /bin/Debug/net5.0 ./
EXPOSE 54349
EXPOSE 80
EXPOSE 443
ENV ASPNETCORE_URLS=http://*:54349
ENV DATABASE_TYPE="SQL SERVER"

RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/' /usr/lib/ssl/openssl.cnf \
&& sed -i 's/CipherString = DEFAULT@SECLEVEL=2/CipherString = DEFAULT@SECLEVEL=1/' /usr/lib/ssl/openssl.cnf

RUN mkdir ./output

COPY entrypoint.sh ./
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

docker-compose.yml

version: "3.9"
services:
  broker:
    image: "myapp"
    build: .
    ports:
      - "8787:54349"
    volumes:
      - ./output:/output_json

entrypoint.sh

#!/bin/bash

set -e
run_cmd="dotnet MyApp.dll"

if [ -z "$DATABASE_STRING" ]; then
  echo "Container failed to start. Please pass a connection string using '-e DATABASE_STRING'."
  exit 1
fi

exec $run_cmd

Calling docker run without passing -e DATABASE_STRING does not raise an error (which it should), making me think that it's not getting into entrypoint.sh at all. Looking in /bin/debug/net 5.0/, I see that it is indeed not in that folder (its Build Action and Copy to Output Directory properties in VS are None and Do Not Copy, respectively).

Should it be in the /bin directory, or is something else going wrong?

JAF
  • 385
  • 1
  • 2
  • 12

0 Answers0