Posted by Anuraj on Wednesday, November 14, 2018 Reading time :1 minute
This post is about running a NuGet server on Docker. When you’re building .NET Core projects, NuGet packages are retrieved from nuget.org by default. Sometimes, however, you might want to use a local NuGet repository. This post helps you to configure a minimal NuGet server on Docker.
The official NuGet.Server package which helps you to run NuGet feeds locally which is not cross platform, so I was looking for some other package and I found BaGet, it is a NuGet server implementation on .NET Core. So you can use the ASP.NET Core runtime as the base image, install the server and run the app. Here is the DockerFile.
First I am using ASP.NET Core runtime as the base image, installing the
unzip utilities. Then I am downloading the BaGet zip from the releases. Since I want to run the server in port 8000, I am setting the
ASPNETCORE_URLS environment variable. The
ApiKeyHash environment variable is used by BaGet as the API Key for NuGet publishing. It is a SHA256 encrypted value for
You can build the container using
docker build command, and run it using
docker run command -
docker run -d -p 8000:8000 --name nugetserver anuraj/baget:latest. Once it is running, you can access it using http://localhost:8000.
You can publish a nuget package using the command -
dotnet nuget push -s http://localhost:8000/v3/index.json .\bin\Debug\AppLogger.1.0.0.nupkg -k NUGET-SERVER-API-KEY
And you can update your nuget.config in Visual Studio, Tools > NuGet Package Manager > Package Manager Settings. And select the Package sources and add your URL and name.
This post was about configuring your own nuget server locally with the help of Docker. You can download the docker image from Docker Hub with command -
docker pull anuraj/baget. And more details available here
Happy Programming :)