dotnet / dotnet/dotnet-docker

Documentation is incorrect for private NuGet feed + Azure Pipelines scenario

Open
#7,088 0 comments 0 reactions 1 assignee Claimed by @lbussell View on GitHub
area-documentation needs-more-info
Dominant language
Dockerfile
Stars
4.9k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
26

Description

### Discussed in https://github.com/dotnet/dotnet-docker/discussions/7067

Originally posted by **mturczyn** March 7, 2026
In documentation/scenarios/nuget-credentials.md it is mentioned we can use Nuget Authenticate task in Azure pipelines
```
- task: Docker@2
displayName: 'build container'
inputs:
command: 'build'
dockerfile: '**/Dockerfile'
arguments: '--build-arg FEED_ACCESSTOKEN=$(VSS_NUGET_ACCESSTOKEN)'
```
But that do not work (even echoing showed it as empty). I guess that might be due to the fact that VSS_NUGET_ACCESSTOKEN is secret value.

I wonder if I am correct about my assumption, or is there something I could do better? Something I have missed?

My workaround currently is to have custom task with docker build and push commands that accepts correctly VSS_NUGET_ACCESSTOKEN secret through environment variables
```
parameters:
- name: acrServer
type: string
- name: containerRepository
type: string
- name: dockerfile
type: string
- name: buildContext
type: string
- name: dockerRegistryServiceConnection
type: string
- name: tags
type: object # array
default: []
- name: push
type: boolean

steps:
- task: NuGetAuthenticate@1
name: NuGetAuthenticate
displayName: "Authenticate with NuGet feed"

- task: Docker@2
displayName: Login to ACR
inputs:
containerRegistry: ${{ parameters.dockerRegistryServiceConnection }}
command: login

- script: |
# Build array of full image URLs
IMAGE_URLS=()
for tag in ${{ join(' ', parameters.tags) }}; do
IMAGE_URLS+=("${{ parameters.acrServer }}/${{ parameters.containerRepository }}:$tag")
done

# Build docker build arguments
BUILD_ARGS=""
for image_url in "${IMAGE_URLS[@]}"; do
BUILD_ARGS="$BUILD_ARGS -t $image_url"
done

docker build \
--build-arg FEED_ACCESSTOKEN="$FEED_ACCESSTOKEN" \
$BUILD_ARGS \
-f ${{ parameters.dockerfile }} \
${{ parameters.buildContext }}

# Push all images (if push is enabled)
if [ "${{ parameters.push }}" == "True" ]; then
for image_url in "${IMAGE_URLS[@]}"; do
echo "Pushing image: $image_url"
docker push "$image_url"
done
else
echo "Push disabled - only building images"
fi
displayName: Build and Push to ACR
env:
FEED_ACCESSTOKEN: $(VSS_NUGET_ACCESSTOKEN) # secret mapped here, not as parameter
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.