2018-02-05 21:05:59 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2015-07-16 21:14:58 +00:00
|
|
|
|
2015-09-24 20:56:57 +00:00
|
|
|
import (
|
2023-03-06 15:02:37 +00:00
|
|
|
"context"
|
|
|
|
|
2016-09-06 18:18:12 +00:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-02-10 20:16:59 +00:00
|
|
|
"github.com/docker/docker/api/types/backend"
|
2016-09-06 18:18:12 +00:00
|
|
|
"github.com/docker/docker/api/types/versions/v1p19"
|
2015-11-12 19:55:17 +00:00
|
|
|
"github.com/docker/docker/container"
|
2015-09-24 20:56:57 +00:00
|
|
|
)
|
2015-07-16 21:14:58 +00:00
|
|
|
|
|
|
|
// This sets platform-specific fields
|
2015-11-12 19:55:17 +00:00
|
|
|
func setPlatformSpecificContainerFields(container *container.Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase {
|
2015-07-16 21:14:58 +00:00
|
|
|
contJSONBase.AppArmorProfile = container.AppArmorProfile
|
|
|
|
contJSONBase.ResolvConfPath = container.ResolvConfPath
|
|
|
|
contJSONBase.HostnamePath = container.HostnamePath
|
|
|
|
contJSONBase.HostsPath = container.HostsPath
|
|
|
|
|
|
|
|
return contJSONBase
|
|
|
|
}
|
|
|
|
|
2015-11-24 17:55:45 +00:00
|
|
|
// containerInspectPre120 gets containers for pre 1.20 APIs.
|
2023-03-06 15:02:37 +00:00
|
|
|
func (daemon *Daemon) containerInspectPre120(ctx context.Context, name string) (*v1p19.ContainerJSON, error) {
|
2019-08-09 12:10:07 +00:00
|
|
|
ctr, err := daemon.GetContainer(name)
|
2015-07-16 21:14:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-08-09 12:10:07 +00:00
|
|
|
ctr.Lock()
|
|
|
|
defer ctr.Unlock()
|
2015-07-16 21:14:58 +00:00
|
|
|
|
2022-08-31 20:12:30 +00:00
|
|
|
base, err := daemon.getInspectData(&daemon.config().Config, ctr)
|
2015-07-16 21:14:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
volumes := make(map[string]string)
|
|
|
|
volumesRW := make(map[string]bool)
|
2019-08-09 12:10:07 +00:00
|
|
|
for _, m := range ctr.MountPoints {
|
2015-07-16 21:14:58 +00:00
|
|
|
volumes[m.Destination] = m.Path()
|
|
|
|
volumesRW[m.Destination] = m.RW
|
|
|
|
}
|
|
|
|
|
2015-11-02 16:28:34 +00:00
|
|
|
return &v1p19.ContainerJSON{
|
|
|
|
ContainerJSONBase: base,
|
|
|
|
Volumes: volumes,
|
|
|
|
VolumesRW: volumesRW,
|
2022-12-28 10:26:44 +00:00
|
|
|
Config: &v1p19.ContainerConfig{
|
|
|
|
Config: ctr.Config,
|
2023-07-04 10:40:35 +00:00
|
|
|
MacAddress: ctr.Config.MacAddress, //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
2022-12-28 10:26:44 +00:00
|
|
|
NetworkDisabled: ctr.Config.NetworkDisabled,
|
|
|
|
ExposedPorts: ctr.Config.ExposedPorts,
|
|
|
|
VolumeDriver: ctr.HostConfig.VolumeDriver,
|
|
|
|
Memory: ctr.HostConfig.Memory,
|
|
|
|
MemorySwap: ctr.HostConfig.MemorySwap,
|
|
|
|
CPUShares: ctr.HostConfig.CPUShares,
|
|
|
|
CPUSet: ctr.HostConfig.CpusetCpus,
|
|
|
|
},
|
|
|
|
NetworkSettings: daemon.getBackwardsCompatibleNetworkSettings(ctr.NetworkSettings),
|
2015-11-02 16:28:34 +00:00
|
|
|
}, nil
|
2015-07-16 21:14:58 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 19:59:00 +00:00
|
|
|
func inspectExecProcessConfig(e *container.ExecConfig) *backend.ExecProcessConfig {
|
2016-02-10 20:16:59 +00:00
|
|
|
return &backend.ExecProcessConfig{
|
2016-03-18 18:50:19 +00:00
|
|
|
Tty: e.Tty,
|
|
|
|
Entrypoint: e.Entrypoint,
|
|
|
|
Arguments: e.Args,
|
|
|
|
Privileged: &e.Privileged,
|
|
|
|
User: e.User,
|
2016-02-10 20:16:59 +00:00
|
|
|
}
|
|
|
|
}
|