I am trying to avoid importing all kinds of dependencies in my docker images (by way of npm or java) so that I can generate a swagger client.
I am using openapitools/openapi-generator-cli but when I try and use it, the command generate
isn't found. Here are the docs
Here's what I'm trying to do:
FROM openapitools/openapi-generator-cli
RUN generate
Result:
Step 1/2 : FROM openapitools/openapi-generator-cli
---> 62d78bf45d59
Step 2/2 : RUN generate
---> Running in accaf10464d5
/bin/sh: 1: generate: not found
However, this works without issue:
docker run openapitools/openapi-generator-cli generate
And by "works" I mean I get positive feedback from the cli that I'm missing the required args.
Being relatively new to this part of Docker, is my understanding incorrect with how FROM
should be working here? I think I'm hitting the error because FROM
doesn't actually run the container and therefore generator
isn't present.
But what confuses me is I do the exact same process with dotnet
and it works perfectly fine.
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim
RUN dotnet
Results:
Step 1/2 : FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim
---> 32aef79fd915
Step 2/2 : RUN dotnet
---> Running in 1e6c04d30a82
Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
CodePudding user response:
docker run openapitools/openapi-generator-cli generate
works because it's equivalent bash /usr/local/bin/docker-entrypoint.sh generate
inside the container
Because from the Dockerfile /usr/local/bin/docker-entrypoint.sh
is set as an ENTRYPOINT
, for you case check docker-entrypoint.sh from the github repo and grasp the logic on what happens when you pass generate, or simply do
FROM openapitools/openapi-generator-cli
RUN bash /usr/local/bin/docker-entrypoint.sh generate