Search code examples
docker.net-coredockerfiledocker-entrypoint

Combining ENTRYPOINT and CMD in Dockerfile targeting different executables


I have a Dockerfile that defines a dotnet ENTRYPOINT. In addition, I have a program that is configured to run under supervisor (with a supervisord.conf definition). When the container is run, I need to start the supervisor service and also pass several args to the ENTRYPOINT executable. I cannot combine ENTRYPOINT and CMD because CMD args are unrelated to ENTRYPOINT. I'd also like to keep the ENTRYPOINT to explicitly have the container wrap dotnet exec. Any thoughts on how this can be accomplished?

I know my scenario works in entirety since I can attach to a running container then starting the supervisor service.

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
…
FROM base AS final    
ENTRYPOINT ["dotnet", "BLAH.dll"]
CMD ["service", "supervisor", "start"]

Solution

  • Looks like you want to run two different services at the same time.
    You can't achieve that through the Dockerfile.

    I suggest you make a script to run both services.
    And use that script in your CMD or ENTRYPOINT in the Dockerfile.