Docker-Compose logging to variable
See original GitHub issueRequired Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Feature/Question
Enter Task Name: Docker-Compose
list here (V# not needed): 0 https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks
Environment
-
Server - Azure Pipelines or TFS on-premises? Azure Pipeline
- If using Azure Pipelines, provide the account name, team project name, build definition name/build number: N/A
-
Agent - Hosted or Private: Hosted agent
- If using Hosted agent, provide agent queue name: N/A
- If using private agent, provide the OS of the machine running the agent and the agent version: N/A
Issue Description
I’m trying to build a script that is able to cache images even on a Hosted Agent. Something similar to this: https://github.com/marketplace/actions/build-docker-images-using-cache and https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
However for this to nicely integrate into Azure DevOps I would like to be able to read out the created identifiers per stage. This can be done quite easily by reading through the log file. E.g.:
In the image above I want to get the Id so that I can execute a docker tag afterwards and tag this specific image as something like devemazegenerator-stages:0
So my main question would be, if it’s possible to somehow storage all logging to a variable during a docker-compose build or docker build.
Regarding directly targeting a stage instead
So in regards to directly targeting a stage instead, like for example calling:
docker build . --stage build
I first thought about using this, but the issue here is that you’re basically doing a docker build twice. I would like to be able to kick-off docker-compose, have all variables / configuration setup there and then afterwards pick-up the stages that I want to push to the registry.
Next to that, it currently seems to be impossible to target an unnamed stage. See: https://forums.docker.com/t/docker-build-first-stage-in-multi-stage-pipeline/91167
Task logs
N/A
Troubleshooting
N/A
Error logs
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Another update, I just found out that apparently the lines
Building ....
are being written to STDERR. I’ve created a bug report for that:https://github.com/docker/compose/issues/7346
If you want to share the contents within a job, you could simply pipe the logs to a file. And use that file path in your scripts within the job.
I checked with @azooinmyluggage, I’ll take your PR forward; it seems like a good addition. 😃