Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Add Debug Log switch (-ld) and Context Log switch (-lcd) to docker build, outputting what’s actually executed #47791

Open
SetTrend opened this issue May 2, 2024 · 0 comments
Labels
area/builder/classic-builder Issues affecting the classic builder area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny status/0-triage

Comments

@SetTrend
Copy link

SetTrend commented May 2, 2024

Description

Running docker build for a Dockerfile, it’s incredibly hard to tell the result of variable replacement or path conversion, particularly when using Windows containers.

Please, add two logging options to docker build, supposed to be outputting the Docker daemon’s context content and the actual result of parsing an instruction:

  1. --log-context-depth {unsigned byte}, or -lcd {unsigned byte}
    (default value: 0)

  2. --log-debug, or -ld


--log-context-depth {unsigned byte}

Providing a --log-context-depth with a value greater than 0 to docker build should result in outputting the content of the Docker daemon’s context in a way that would allow to copy/paste individual entries of the log output to a COPY instruction, i.e., this option should output absolute paths in a format that’s accepted by the COPY instruction. The depth value is supposed to be used to limit the depth of sub directorys being output.

Examples

Given the following folder structure:

Dockerfile
My Folder
|-- My Sub Folder
|   |-- My Sub File 1.txt
|   |-- My Sub File 2.txt
|   |-- My Sub Sub Folder
|   |   |-- My Sub Sub File 1.txt
|   |   |-- My Sub Sub File 2.txt
|-- My File 1.txt
|-- My File 2.txt

This is the suggested output when using --log-context-depth:

> docker build -lcd 1 ...
Sending build context to Docker daemon
Context content:
-----------------------------------------
"\Dockerfile"
"\My Folder\"
-----------------------------------------

log context output 1

> docker build -lcd 2 ...
Sending build context to Docker daemon
Context content:
-----------------------------------------
"\Dockerfile"
"\My Folder\"
"\My Folder\My Sub Folder\"
"\My Folder\My File 1.txt"
"\My Folder\My File 2.txt"
-----------------------------------------

log context output 2


--log-debug

Providing this command line argument should result in logging the actual instruction that’s being executed in the writable layer of the container, after variables have been replaced and paths have been canonicalized.

Examples

Given a Dockerfile content like this:

# escape=`
FROM mcr.microsoft.com/windows/servercore:20H2
ENV myPath="C:\Program Files\"
COPY "My Sub Folder\..\MyProg\" "${myPath}My Prog\"

This is the suggested output when using --log-debug:

> docker build -ld ...
Sending build context to Docker daemon
Step 1/3 : FROM mcr.microsoft.com/windows/servercore:20H2
FROM https://hub.docker.com/mcr.microsoft.com/windows/servercore:20H2
---> d7c03b5bcc73
Step 2/3 : ENV myPath="C:\Program Files\"
 ---> c8c23a14f7f3
Step 3/3 : COPY "My Sub Folder\..\MyProg\" "${myPath}My Prog\"
COPY "\MyProg\" "C:\Program Files\My Prog\"

log debug output

@SetTrend SetTrend added kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny status/0-triage labels May 2, 2024
@thaJeztah thaJeztah added area/builder area/builder/classic-builder Issues affecting the classic builder labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder/classic-builder Issues affecting the classic builder area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny status/0-triage
Projects
None yet
Development

No branches or pull requests

2 participants