@@ -29,6 +29,10 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
2929 return nil , err
3030 }
3131
32+ if err := daemon .setupConfigDir (c ); err != nil {
33+ return nil , err
34+ }
35+
3236 // In s.Mounts
3337 mounts , err := daemon .setupMounts (c )
3438 if err != nil {
@@ -44,24 +48,25 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
4448 isHyperV = c .HostConfig .Isolation .IsHyperV ()
4549 }
4650
47- // If the container has not been started, and has secrets, create symlinks
48- // to each secret. If it has been started before, the symlinks should have
49- // already been created. Also, it is important to not mount a Hyper-V
50- // container that has been started before, to protect the host from the
51- // container; for example, from malicious mutation of NTFS data structures.
52- if ! c .HasBeenStartedBefore && len (c .SecretReferences ) > 0 {
51+ // If the container has not been started, and has configs or secrets
52+ // secrets, create symlinks to each confing and secret. If it has been
53+ // started before, the symlinks should have already been created. Also, it
54+ // is important to not mount a Hyper-V container that has been started
55+ // before, to protect the host from the container; for example, from
56+ // malicious mutation of NTFS data structures.
57+ if ! c .HasBeenStartedBefore && (len (c .SecretReferences ) > 0 || len (c .ConfigReferences ) > 0 ) {
5358 // The container file system is mounted before this function is called,
5459 // except for Hyper-V containers, so mount it here in that case.
5560 if isHyperV {
5661 if err := daemon .Mount (c ); err != nil {
5762 return nil , err
5863 }
64+ defer daemon .Unmount (c )
5965 }
60- err := c .CreateSecretSymlinks ()
61- if isHyperV {
62- daemon .Unmount (c )
66+ if err := c .CreateSecretSymlinks (); err != nil {
67+ return nil , err
6368 }
64- if err != nil {
69+ if err := c . CreateConfigSymlinks (); err != nil {
6570 return nil , err
6671 }
6772 }
@@ -70,6 +75,10 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
7075 mounts = append (mounts , m ... )
7176 }
7277
78+ if m := c .ConfigMounts (); m != nil {
79+ mounts = append (mounts , m ... )
80+ }
81+
7382 for _ , mount := range mounts {
7483 m := specs.Mount {
7584 Source : mount .Source ,
0 commit comments