You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build-secrets.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,10 @@ cat << EOF > devcontainer.json
32
32
}
33
33
}
34
34
EOF
35
+
echo'runtime-secret-a'> runtime-secret.txt
35
36
```
36
37
37
-
The Dockerfile requires two secrets: `TEST_BUILD_SECRET_A` and `TEST_BUILD_SECRET_B`. Their values are arbitrarily set to `secret-foo` and `secret-bar` by the command below. Building the container image writes the checksums for these secrets to disk. This illustrates that the secrets can be used in the build to enact side effects without exposing the secrets themselves.
38
+
The Dockerfile requires two build secrets: `TEST_BUILD_SECRET_A` and `TEST_BUILD_SECRET_B`. Their values are arbitrarily set to `secret-foo` and `secret-bar` by the command below. Building the container image writes the checksums for these secrets to disk. This illustrates that the secrets can be used in the build to enact side effects without exposing the secrets themselves.
This will result in a shell session inside the built container.
51
-
You can now verify two things:
53
+
You can now verify three things:
52
54
53
55
Firstly, the secrets provided to build are not available once the container is running. They are no longer on disk, nor are they in the process environment, or in `/proc/self/environ`:
54
56
```bash
@@ -82,7 +84,7 @@ DEVCONTAINER=true
82
84
/workspaces/empty #
83
85
```
84
86
85
-
Finally, the secrets were still useful during the build. The following commands show that the secrets had side effects inside the build, without remaining in the image:
87
+
Secondly, the secrets were still useful during the build. The following commands show that the secrets had side effects inside the build, without remaining in the image:
Thirdly, the runtime secret that was mounted as a volume is still mounted into the container and accessible. This is why volumes are inappropriate analogues to native docker build secrets. However, notice further down that this runtime secret volume's contents are not present in the built image. It is therefore safe to mount a volume into envbuilder for use during runtime without fear that it will be present in the image that envbuilder builds.
109
+
106
110
Finally, exit the container:
107
111
```bash
108
112
exit
@@ -120,13 +124,15 @@ cd test-container
120
124
# Scan image layers for secrets:
121
125
find . -type f | xargs tar -xOf 2>/dev/null | strings | grep -rn "secret-foo"
122
126
find . -type f | xargs tar -xOf 2>/dev/null | strings | grep -rn "secret-bar"
127
+
find . -type f | xargs tar -xOf 2>/dev/null | strings | grep -rn "runtime-secret"
123
128
# Scan image manifests for secrets:
124
129
find . -type f | xargs -n1 grep -rnI 'secret-foo'
125
130
find . -type f | xargs -n1 grep -rnI 'secret-bar'
131
+
find . -type f | xargs -n1 grep -rnI 'runtime-secret'
126
132
cd ../
127
133
```
128
134
129
-
The output of both find/grep commands should be empty.
135
+
The output of all find/grep commands should be empty.
130
136
To verify that it scans correctly, replace "secret-foo" with "envbuilder" and rerun the commands. It should find strings related to Envbuilder that are not secrets.
0 commit comments