docker inspect output parsing fails on Windows
See original GitHub issueEnvironment:
- Jib version: 2.0.0
- Build tool: Gradle 5.6.2
- OS: Windows 10
Description of the issue:
Output from docker inspect
is not valid JSON on Windows and so the parsing fails on following error:
Execution failed for task ':jibDockerBuild'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Unexpected character ('s' (code 115)): was expecting double-quote to start field name
at [Source: (String)"{size:11421955405,imageId:sha256:68204dc2fc12499d321ef43f00c439bbf2300b280d14737a92841d4b22ddd58c,diffIds:["sha256:f358be10862ccbc329638b9e10b3d497dd7cd28b0e8c7931b4a545c88d7f7cd6","sha256:ffce47ae4ffd0b88677730d9949223ae0f4de9c7b14fd7f23112a1724381dac8","sha256:9fb133e2afa1efc256864786d3fe44c896e171aebb52255e44bc5a6e38024ece","sha256:54f1b480fa3dca5845816d23b22bdb748d0fa22217ae9387121683dfe403da5a","sha256:e2e665092bb91d64c1fab2d3e6b5a80f3a52388badd5df17704f57405c81ad03","sha256:f47af1187470c38"[truncated 422 chars]; line: 1, column: 3]
See also this report
The docker inspect
is issued when using base Docker image from daemon (instead of from registry), see the docker://
prefix below. It’s possible that docker inspect
is used also in different use-cases.
Expected behavior:
jib
doesn’t fail on invalid JSON parsing, when running on Windows and using base image from Docker daemon.
Steps to reproduce:
- Use
build.gradle
as shown below. - Execute
jibDockerBuild
.
jib-gradle-plugin
Configuration:
jib {
from {
image = 'docker://my-image:1.0.0'
}
}
Log output:
Execution failed for task ':server:jibDockerBuild'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Unexpected character ('s' (code 115)): was expecting double-quote to start field name
at [Source: (String)"{size:513050736,imageId:sha256:6bf020e553c504672ab41c4ee45c008d331aba465ad0f8d99752d75aa830b7c4,diffIds:["sha256:d69483a6face4499acb974449d1303591fcbb5cdce5420f36f8a6607bda11854","sha256:fa546c09dbca96caa9a87ce37518b215364492deeb58dc8f4e5884ed65ae67ad","sha256:fab7516865bc195a22c493e9a7222c8e42ebf21c0d78f443c0d0bd53a0abae84","sha256:8741a416c3f1340e9cd95c049332b5c7dbbee05d8c3cbe52dd67dd48ab760d4f","sha256:7fef8cf5257ba113bf651c0acfec5f5a03ea5c872b1f31f8ca7b968bc6d20f81"]}"; line: 1, column: 3]
Additional Information: The problem is in this method. If I tried to execute the command manually then I really got invalid JSON:
D:\Work>docker inspect -f "{"size":{{.Size}},"imageId":"{{.Id}}","diffIds":{{json .RootFS.Layers}}}" --type image openjdk:11.0.1-windowsservercore-ltsc2016
{size:11421955405,imageId:sha256:68204dc2fc12499d321ef43f00c439bbf2300b280d14737a92841d4b22ddd58c,diffIds:["sha256:f358be10862ccbc329638b9e10b3d497dd7cd28b0e8c7931b4a545c88d7f7cd6","sha256:ffce47ae4ffd0b88677730d9949223ae0f4de9c7b14fd7f23112a1724381dac8","sha256:9fb133e2afa1efc256864786d3fe44c896e171aebb52255e44bc5a6e38024ece","sha256:54f1b480fa3dca5845816d23b22bdb748d0fa22217ae9387121683dfe403da5a","sha256:e2e665092bb91d64c1fab2d3e6b5a80f3a52388badd5df17704f57405c81ad03","sha256:f47af1187470c38d468414f8ff92ac928930386da466c0d6b27bb8f5b37c7442","sha256:a89f3bd646ef45a00237d10e870b50b16d0f203ea970be8f07588e071dd2020d","sha256:3951066b4972f280ccdbaa3fd59ae91e295e1cc38b138a14d7d377e16ee992bd","sha256:cfd212e34afa290dc5c780eb684c56477f21f1803af3341fbef59a38a18048a7","sha256:68d52bc69bc5310bb9d442ac1a828355146e698a72ff3639bb192ba14579eaf4","sha256:8baf500f12aeb8dadde42b0aa8bf444e201001170145952838a1e84c74802bfa"]}
The solution is to use triple-doublequotes to ensure doublequotes are present in the output:
D:\Work>docker inspect -f "{"""size""":{{.Size}},"""imageId""":"""{{.Id}}""","""diffIds""":{{json .RootFS.Layers}}}" --type image openjdk:11.0.1-windowsservercore-ltsc2016
{"size":11421955405,"imageId":"sha256:68204dc2fc12499d321ef43f00c439bbf2300b280d14737a92841d4b22ddd58c","diffIds":["sha256:f358be10862ccbc329638b9e10b3d497dd7cd28b0e8c7931b4a545c88d7f7cd6","sha256:ffce47ae4ffd0b88677730d9949223ae0f4de9c7b14fd7f23112a1724381dac8","sha256:9fb133e2afa1efc256864786d3fe44c896e171aebb52255e44bc5a6e38024ece","sha256:54f1b480fa3dca5845816d23b22bdb748d0fa22217ae9387121683dfe403da5a","sha256:e2e665092bb91d64c1fab2d3e6b5a80f3a52388badd5df17704f57405c81ad03","sha256:f47af1187470c38d468414f8ff92ac928930386da466c0d6b27bb8f5b37c7442","sha256:a89f3bd646ef45a00237d10e870b50b16d0f203ea970be8f07588e071dd2020d","sha256:3951066b4972f280ccdbaa3fd59ae91e295e1cc38b138a14d7d377e16ee992bd","sha256:cfd212e34afa290dc5c780eb684c56477f21f1803af3341fbef59a38a18048a7","sha256:68d52bc69bc5310bb9d442ac1a828355146e698a72ff3639bb192ba14579eaf4","sha256:8baf500f12aeb8dadde42b0aa8bf444e201001170145952838a1e84c74802bfa"]}
So IMHO the solution is to use slightly different command, based on current OS.
I’m willing to prepare a PR for this. It would be great if you suggested me the preferred way how to detect Windows OS.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
@chanseokoh Please see #2288 - this is another issue with Windows Containers. Maybe the fix will be part of #1568
If I can help, just let me know.
@augi it’s easy to build it yourself.
This will build 2.0.1-SNAPSHOT and install it into your local Maven repo (
~/.m2/repository
). Then configure your build script at the beginning likeThanks for testing this out! I’m curious too.