I'm in a weird situation trying to run a Docker image
The image is failing for not finding the dotnet, so then I connected to it to run manually the commands and see what's going on.
My structure is:
- Docker:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
RUN apt-get update && apt-get -y install python3-pip
WORKDIR /app
COPY requirements.txt .
COPY publish .
COPY IRT .
COPY start.sh .
RUN chmod u+x ./start.sh
RUN pip3 install -r requirements.txt
ENTRYPOINT ["sh", "start.sh"]
- start.sh (simplified for show the problem)
timeout 15s ping google.com | grep -m 1 "icmp_seq=6" && dotnet Gatekeeper.dll
The Problem
If I run sh start.sh, this is the output:
root@c53ecc22b25f:/app# sh start.sh
: not found: start.sh:
64 bytes from 216.58.211.110 (216.58.211.110): icmp_seq=6 ttl=37 time=15.9 ms
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
BUT, If I run the command itself without calling the start.sh, it works perfectly:
root@c53ecc22b25f:/app# timeout 15s ping google.com | grep -m 1 "icmp_seq=6" && dotnet Gatekeeper.dll
64 bytes from 172.217.17.78 (172.217.17.78): icmp_seq=6 ttl=37 time=23.1 ms
info: AWSSDK[0]
Found AWS options in IConfiguration
info: AWSSDK[0]
Found credentials using the AWS SDK's default credential search
...
I have already tried to use the full path for dotnet (/usr/bin/dotnet) but still it doesn't work.
Also something very weird. if I modify the start.sh to have only dotnet Gatekeeper.dll, it works.
I am not very experienced with linux sh and have no idea why this is happening. Can you help me ?
Extra: Why do I need this command?
- I run 2 servers for the entrypoint, a python server that is required to be ready before the Dotnet start, otherwise I have a kind of "Cold start" error on my containers.
- I have already a workaround where I modify the c# code to keep trying to connect to for some seconds and then proceed with the startup, but this is not ideal for several reasons.