inspect_unix.go 1.9 KB

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