inspect_unix.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // +build !windows
  2. package daemon
  3. import "github.com/docker/docker/api/types"
  4. // This sets platform-specific fields
  5. func setPlatformSpecificContainerFields(container *Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase {
  6. contJSONBase.AppArmorProfile = container.AppArmorProfile
  7. contJSONBase.ResolvConfPath = container.ResolvConfPath
  8. contJSONBase.HostnamePath = container.HostnamePath
  9. contJSONBase.HostsPath = container.HostsPath
  10. return contJSONBase
  11. }
  12. // ContainerInspectPre120 gets containers for pre 1.20 APIs.
  13. func (daemon *Daemon) ContainerInspectPre120(name string) (*types.ContainerJSONPre120, error) {
  14. container, err := daemon.Get(name)
  15. if err != nil {
  16. return nil, err
  17. }
  18. container.Lock()
  19. defer container.Unlock()
  20. base, err := daemon.getInspectData(container)
  21. if err != nil {
  22. return nil, err
  23. }
  24. volumes := make(map[string]string)
  25. volumesRW := make(map[string]bool)
  26. for _, m := range container.MountPoints {
  27. volumes[m.Destination] = m.Path()
  28. volumesRW[m.Destination] = m.RW
  29. }
  30. config := &types.ContainerConfigPre120{
  31. container.Config,
  32. container.hostConfig.VolumeDriver,
  33. container.hostConfig.Memory,
  34. container.hostConfig.MemorySwap,
  35. container.hostConfig.CPUShares,
  36. container.hostConfig.CpusetCpus,
  37. }
  38. return &types.ContainerJSONPre120{base, volumes, volumesRW, config}, nil
  39. }
  40. func addMountPoints(container *Container) []types.MountPoint {
  41. mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
  42. for _, m := range container.MountPoints {
  43. mountPoints = append(mountPoints, types.MountPoint{
  44. Name: m.Name,
  45. Source: m.Path(),
  46. Destination: m.Destination,
  47. Driver: m.Driver,
  48. Mode: m.Mode,
  49. RW: m.RW,
  50. })
  51. }
  52. return mountPoints
  53. }