@@ -109,14 +109,20 @@ func (m command) run(c *cli.Context, cfg *options) error {
109
109
}
110
110
111
111
containerRootDir , err := s .GetContainerRoot ()
112
- if err != nil {
112
+ if err != nil || containerRootDir == "" || containerRootDir == "/" {
113
113
return fmt .Errorf ("failed to determined container root: %v" , err )
114
114
}
115
115
116
116
ldconfigPath := m .resolveLDConfigPath (cfg .ldconfigPath )
117
- args := []string {filepath .Base (ldconfigPath )}
118
- if containerRootDir != "" {
119
- args = append (args , "-r" , containerRootDir )
117
+ args := []string {
118
+ filepath .Base (ldconfigPath ),
119
+ // Run ldconfig in the container root directory on the host.
120
+ "-r" , containerRootDir ,
121
+ // Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
122
+ // be configured to use a different config file by default.
123
+ // Note that since we apply the `-r {{ .containerRootDir }}` argument, /etc/ld.so.conf is
124
+ // in the container.
125
+ "-f" , "/etc/ld.so.conf" ,
120
126
}
121
127
122
128
containerRoot := containerRoot (containerRootDir )
@@ -138,10 +144,6 @@ func (m command) run(c *cli.Context, cfg *options) error {
138
144
args = append (args , folders ... )
139
145
}
140
146
141
- // Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
142
- // be configured to use a different config file by default.
143
- args = append (args , "-f" , "/etc/ld.so.conf" )
144
-
145
147
return m .SafeExec (ldconfigPath , args , nil )
146
148
}
147
149
0 commit comments