@@ -35,23 +35,35 @@ const (
35
35
{{ range $i, $a := .AdditionalArguments -}}
36
36
{{ $a }} \
37
37
{{ end -}}
38
- ubuntu sleep infinity`
38
+ {{.OuterContainerImage}} sleep infinity`
39
39
40
40
installDockerTemplate = `
41
41
export DEBIAN_FRONTEND=noninteractive
42
42
43
43
# Add Docker official GPG key:
44
44
apt-get update
45
- apt-get install -y ca-certificates curl apt-utils gnupg2
45
+ apt-get install -y apt-utils ca-certificates curl gnupg2
46
46
install -m 0755 -d /etc/apt/keyrings
47
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
47
+
48
+ # Read OS information from /etc/os-release
49
+ . /etc/os-release
50
+
51
+ if [ "${ID}" = "debian" ]; then
52
+ curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
53
+ else
54
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
55
+ fi
48
56
chmod a+r /etc/apt/keyrings/docker.asc
49
57
50
58
# Add the repository to Apt sources:
51
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \"${UBUNTU_CODENAME:-$VERSION_CODENAME}\") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
59
+ if [ "${ID}" = "debian" ]; then
60
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian ${VERSION_CODENAME} stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
61
+ else
62
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${UBUNTU_CODENAME:-$VERSION_CODENAME} stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
63
+ fi
52
64
apt-get update
53
65
54
- apt-get install -y docker-ce docker-ce-cli containerd.io
66
+ apt-get install -y docker-ce docker-ce-cli
55
67
56
68
# start dockerd in the background
57
69
dockerd &
@@ -98,7 +110,6 @@ type nestedContainerRunner struct {
98
110
}
99
111
100
112
type runnerOption func (* remoteRunner )
101
- type nestedContainerOption func (* nestedContainerRunner )
102
113
103
114
type Runner interface {
104
115
Run (script string ) (string , string , error )
@@ -146,7 +157,7 @@ func NewRunner(opts ...runnerOption) Runner {
146
157
// NewNestedContainerRunner creates a new nested container runner.
147
158
// A nested container runs a container inside another container based on a
148
159
// given runner (remote or local).
149
- func NewNestedContainerRunner (runner Runner , installCTK bool , image string , containerName string , opts ... nestedContainerOption ) (Runner , error ) {
160
+ func NewNestedContainerRunner (runner Runner , baseImage string , installCTK bool , image string , containerName string ) (Runner , error ) {
150
161
additionalContainerArguments := []string {}
151
162
152
163
// If a container with the same name exists from a previous test run, remove it first.
@@ -222,6 +233,9 @@ func NewNestedContainerRunner(runner Runner, installCTK bool, image string, cont
222
233
}
223
234
}
224
235
236
+ // Mount the /lib/modules directory as a volume to enable the nvidia-cdi-refresh service
237
+ additionalContainerArguments = append (additionalContainerArguments , "-v /lib/modules:/lib/modules" )
238
+
225
239
// Launch the container in detached mode.
226
240
var outerContainerScriptBuilder strings.Builder
227
241
outerContainerTemplate , err := template .New ("outerContainer" ).Parse (outerContainerTemplate )
@@ -231,9 +245,11 @@ func NewNestedContainerRunner(runner Runner, installCTK bool, image string, cont
231
245
err = outerContainerTemplate .Execute (& outerContainerScriptBuilder , struct {
232
246
ContainerName string
233
247
AdditionalArguments []string
248
+ OuterContainerImage string
234
249
}{
235
250
ContainerName : containerName ,
236
251
AdditionalArguments : additionalContainerArguments ,
252
+ OuterContainerImage : baseImage ,
237
253
})
238
254
if err != nil {
239
255
return nil , fmt .Errorf ("failed to execute start container template: %w" , err )
0 commit comments