@@ -35,23 +35,35 @@ const (
3535 {{ range $i, $a := .AdditionalArguments -}}
3636 {{ $a }} \
3737 {{ end -}}
38- ubuntu sleep infinity`
38+ {{.OuterContainerImage}} sleep infinity`
3939
4040 installDockerTemplate = `
4141 export DEBIAN_FRONTEND=noninteractive
4242
4343 # Add Docker official GPG key:
4444 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
4646 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
4856 chmod a+r /etc/apt/keyrings/docker.asc
4957
5058 # 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
5264 apt-get update
5365
54- apt-get install -y docker-ce docker-ce-cli containerd.io
66+ apt-get install -y docker-ce docker-ce-cli
5567
5668 # start dockerd in the background
5769 dockerd &
@@ -98,7 +110,6 @@ type nestedContainerRunner struct {
98110}
99111
100112type runnerOption func (* remoteRunner )
101- type nestedContainerOption func (* nestedContainerRunner )
102113
103114type Runner interface {
104115 Run (script string ) (string , string , error )
@@ -146,7 +157,7 @@ func NewRunner(opts ...runnerOption) Runner {
146157// NewNestedContainerRunner creates a new nested container runner.
147158// A nested container runs a container inside another container based on a
148159// 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 ) {
150161 additionalContainerArguments := []string {}
151162
152163 // 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
222233 }
223234 }
224235
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+
225239 // Launch the container in detached mode.
226240 var outerContainerScriptBuilder strings.Builder
227241 outerContainerTemplate , err := template .New ("outerContainer" ).Parse (outerContainerTemplate )
@@ -231,9 +245,11 @@ func NewNestedContainerRunner(runner Runner, installCTK bool, image string, cont
231245 err = outerContainerTemplate .Execute (& outerContainerScriptBuilder , struct {
232246 ContainerName string
233247 AdditionalArguments []string
248+ OuterContainerImage string
234249 }{
235250 ContainerName : containerName ,
236251 AdditionalArguments : additionalContainerArguments ,
252+ OuterContainerImage : baseImage ,
237253 })
238254 if err != nil {
239255 return nil , fmt .Errorf ("failed to execute start container template: %w" , err )
0 commit comments