jhhwilliams
jhhwilliams

Reputation: 2582

Why is Azure Pipelines Docker task buildContext empty?

I'm running a pipeline and cannot figure out why the buildContext in the Docker task is empty even though the cmd script clearly shows that the directory is not?

The tasks in my azure-pipelines.yml are as follows:

- task: CmdLine@2
  inputs:
    workingDirectory: './services/UI.Web'
    script: 'dir'

- task: Docker@2
  inputs:
    command: 'buildAndPush'
    containerRegistry: 'docker'
    repository: 'username/repository'
    Tags: tag
    Dockerfile: './services/UI.Web/Dockerfile'
    buildContext: './services/UI.Web'

The output in the pipeline logs are as follows:

Directory of D:\a\1\s\services\UI.Web

... list of files and folders ...

10 File(s) 18 Dir(s) 179,798 bytes

and

"C:\Program Files\Docker\docker.exe" build -f D:\a\1\s\services\UI.Web\Dockerfile -t username/repository:tag D:\a\1\s\services\UI.Web
Sending build context to Docker daemon  3.072kB

If I change the buildContext to './services' then the log output changes to

"C:\Program Files\Docker\docker.exe" build -f d:\a\1\s\services\UI.Web\Dockerfile -t username/repository:tag d:\a\1\s\services
Sending build context to Docker daemon  2.701GB

Upvotes: 0

Views: 2624

Answers (1)

jhhwilliams
jhhwilliams

Reputation: 2582

  1. Make sure you don't have a .dockerignore file with a solitary *.
  2. Make sure you've done 1

Such a rookie mistake so hopefully this can save other people the hours it took me to figure it out.

Upvotes: 2

Related Questions