github.com/coreos/docker@v1.13.1/daemon/inspect_unix.go (about) 1 // +build !windows,!solaris 2 3 package daemon 4 5 import ( 6 "github.com/docker/docker/api/types" 7 "github.com/docker/docker/api/types/backend" 8 "github.com/docker/docker/api/types/versions/v1p19" 9 "github.com/docker/docker/container" 10 "github.com/docker/docker/daemon/exec" 11 ) 12 13 // This sets platform-specific fields 14 func setPlatformSpecificContainerFields(container *container.Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase { 15 contJSONBase.AppArmorProfile = container.AppArmorProfile 16 contJSONBase.ResolvConfPath = container.ResolvConfPath 17 contJSONBase.HostnamePath = container.HostnamePath 18 contJSONBase.HostsPath = container.HostsPath 19 20 return contJSONBase 21 } 22 23 // containerInspectPre120 gets containers for pre 1.20 APIs. 24 func (daemon *Daemon) containerInspectPre120(name string) (*v1p19.ContainerJSON, error) { 25 container, err := daemon.GetContainer(name) 26 if err != nil { 27 return nil, err 28 } 29 30 container.Lock() 31 defer container.Unlock() 32 33 base, err := daemon.getInspectData(container, false) 34 if err != nil { 35 return nil, err 36 } 37 38 volumes := make(map[string]string) 39 volumesRW := make(map[string]bool) 40 for _, m := range container.MountPoints { 41 volumes[m.Destination] = m.Path() 42 volumesRW[m.Destination] = m.RW 43 } 44 45 config := &v1p19.ContainerConfig{ 46 Config: container.Config, 47 MacAddress: container.Config.MacAddress, 48 NetworkDisabled: container.Config.NetworkDisabled, 49 ExposedPorts: container.Config.ExposedPorts, 50 VolumeDriver: container.HostConfig.VolumeDriver, 51 Memory: container.HostConfig.Memory, 52 MemorySwap: container.HostConfig.MemorySwap, 53 CPUShares: container.HostConfig.CPUShares, 54 CPUSet: container.HostConfig.CpusetCpus, 55 } 56 networkSettings := daemon.getBackwardsCompatibleNetworkSettings(container.NetworkSettings) 57 58 return &v1p19.ContainerJSON{ 59 ContainerJSONBase: base, 60 Volumes: volumes, 61 VolumesRW: volumesRW, 62 Config: config, 63 NetworkSettings: networkSettings, 64 }, nil 65 } 66 67 func addMountPoints(container *container.Container) []types.MountPoint { 68 mountPoints := make([]types.MountPoint, 0, len(container.MountPoints)) 69 for _, m := range container.MountPoints { 70 mountPoints = append(mountPoints, types.MountPoint{ 71 Type: m.Type, 72 Name: m.Name, 73 Source: m.Path(), 74 Destination: m.Destination, 75 Driver: m.Driver, 76 Mode: m.Mode, 77 RW: m.RW, 78 Propagation: m.Propagation, 79 }) 80 } 81 return mountPoints 82 } 83 84 func inspectExecProcessConfig(e *exec.Config) *backend.ExecProcessConfig { 85 return &backend.ExecProcessConfig{ 86 Tty: e.Tty, 87 Entrypoint: e.Entrypoint, 88 Arguments: e.Args, 89 Privileged: &e.Privileged, 90 User: e.User, 91 } 92 }