Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To generate a Docker image by using an internal NuGet package that is reachable through an internal network path, follow these steps:

  1. Create a Dockerfile that includes the necessary steps to install and configure your NuGet client. For example, you might use the following code snippet:
FROM microsoft/dotnet:2.2-sdk
WORKDIR /app
COPY . .
RUN dotnet tool install --global NuGet.CommandLine
ENV PATH="${PATH}:/root/.dotnet/tools"
  1. Add a RUN command to your Dockerfile that uses the nuget CLI to restore your packages from your internal NuGet feed. For example:
RUN nuget sources add -name MyNuGetFeed -source \\server\path\to\feed
RUN nuget restore MyProject.csproj -Source MyNuGetFeed
  1. Continue building your Docker image by adding any additional steps necessary to configure your application and its dependencies.

  2. Build your Docker image using the docker build command. Make sure you are running the command in a context that has access to your internal network path.

docker build -t my-image .
  1. Optionally, you can also store your Docker image in a Docker registry for easier distribution and deployment. You can use a private registry that is accessible over your internal network or a public registry like Docker Hub. To push your image to a registry, use the docker push command.
docker push my-registry/my-image

Overall, the key steps for generating a Docker image using an internal NuGet package that is reachable through an internal network path are to configure your NuGet client, restore your packages from your internal feed, and then continue building your Docker image as usual.