azure-pipelines-tasks: [BUG]: No data was written into the file (Docker@2)

Task name

Docker@2

Task version

2.214.0

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Debian 11

Issue Description

I am getting this warning:

##[warning]No data was written into the file /home/vsts/work/_temp/task_outputs/build_****.txt

This was originally brought up in https://github.com/microsoft/azure-pipelines-tasks/issues/12470 but the issue was closed without it being resolved. Many users (including myself) are still facing this issue.

Task log

. . .
#8 exporting to image
#8 sha256:***
#8 exporting layers done
#8 writing image sha256:*** done
#8 naming to *** done
#8 DONE 0.0s
##[warning]No data was written into the file /__w/_temp/task_outputs/build_***.txt
Finishing: Docker build

Aditional info

- task: Docker@2
  inputs:
    command: 'build'

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 63
  • Comments: 18

Most upvoted comments

Workaround # 4:

Similar the the ones above, but this sets it for the entire stage/job in the yaml.

variables:
- name: DOCKER_BUILDKIT
  value: 1

In case anyone doesn’t realize it, BuildKit became the default builder starting in Docker 23. BuildKit acts differently than the old builder, sending no output to stdout. That’s what the original ticket was about. The fix for the original ticket was to detect when BuildKit was enabled by looking at the DOCKER_BUILDKIT environment variable and acting appropriately when it was set. But with Docker 23 BuildKit is enable by default even if you don’t have DOCKER_BUILDKIT defined. But in that case the task doesn’t know you are using BuildKit so it expects the old builder behavior. This is why the workaround mentioned above of defining DOCKER_BUILDKIT works.

We use a self-hosted agent and when I started using Docker 23 on it, I defined DOCKER_BUILDKIT at the agent level, so it’s always defined for all jobs. So I have not run into this error again.

Same problem, solution Workaround # 4 is no longer working

I am still getting this, even on a hosted agent AND with DOCKER_BUILDKIT set to 1.

Another echoing of the chorus, we just started getting this on Azure Pipelines hosted agents in the past 24-48 hours on Docker@2 tasks. However it’s not breaking luckily for us anyway, will attempt to look into some of the workarounds if we get time.

In case anyone doesn’t realize it, BuildKit became the default builder starting in Docker 23. BuildKit acts differently than the old builder, sending no output to stdout. That’s what the original ticket was about. The fix for the original ticket was to detect when BuildKit was enabled by looking at the DOCKER_BUILDKIT environment variable and acting appropriately when it was set. But with Docker 23 BuildKit is enable by default even if you don’t have DOCKER_BUILDKIT defined. But in that case the task doesn’t know you are using BuildKit so it expects the old builder behavior. This is why the workaround mentioned above of defining DOCKER_BUILDKIT works.

We use a self-hosted agent and when I started using Docker 23 on it, I defined DOCKER_BUILDKIT at the agent level, so it’s always defined for all jobs. So I have not run into this error again.

thanks for sharing this info, I didn’t realize it. Great that you highlighted what’s going on in the back.

can confirm having the same issue using a VMSS pool using the Ubuntu Minimal LTS 22.04 image canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts-gen2:latest

using this docker version

 Version:           23.0.4
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        f480fb1
 Built:             Fri Apr 14 10:32:03 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.4
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       cbce331
  Built:            Fri Apr 14 10:32:03 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
So far this is the best workaround I have found. This sets the environment variable globally which gets rid of the warning.

Workaround # 3:

Edit the runsvc.sh file in the agent directory and add the following export, then restart the agent service.

# insert anything to setup env when running as a service
export DOCKER_BUILDKIT=1

EDIT:

This method does not seem to work consistently.

Just found another workaround. If you are using the newer version of Docker, just make sure you define the BuildKit env var in the task. The value doesn't seem to matter so you can use 0 or 1 to get rid of the error. It will be a pain to set this env in every task across every project. If anybody has a solution to do this at a global level please let me know. I have tried setting the buildkit feature in the daemon.json on the host and restarted the service but the pipeline still throws the warning.

Workaround # 2:

  - task: Docker@2
    inputs:
      command: 'build'
    env:
      DOCKER_BUILDKIT: 1

EDIT:

This method does not seem to work consistently.

I have done some troubleshooting and may have stumbled upon something. I noticed that one of our agents do not get this error so I started doing some comparison with the other agents. It was running an older version of docker. I upgraded docker to match the version of the other agents and all the sudden it also started to get the error. I downgraded docker back to original and the error went away.

Here are my findings:

Version status
docker-ce-3:20.10.21-3.el8.x86_64 fine
docker-ce-3:23.0.1-1.el8.x86_64 broken
docker-ce-3:23.0.3-1.el8.x86_64 broken

So far I have not found any issues with downgrading. BuildKit still works fine. Hopefully Microsoft will provide an update to this Docker@2 extension for the newer docker versions.

Here is what I did to “fix” the other agents.

Workaround # 1:

sudo yum remove \
	docker-buildx-plugin \
	docker-ce \
	docker-ce-cli \
	docker-ce-rootless-extras

sudo yum install \
	docker-ce-3:20.10.9-3.el7.x86_64 \
	docker-ce-cli-1:20.10.21-3.el7.x86_64 \
	docker-ce-rootless-extras-20.10.21-3.el7.x86_64

Having the same issue on same self-hosted Linux agent with the same task.