Repository: moby/moby
File: daemon/inspect.go (Go)

Code before:
		HostConfig:   &hostConfig,
		Config:       ctr.Config,
	}

	// Now set any platform-specific fields
	inspectResponse = setPlatformSpecificContainerFields(ctr, inspectResponse)

	if daemon.UsesSnapshotter() {
		inspectResponse.Storage = &storage.Storage{
			RootFS: &storage.RootFSStorage{
				Snapshot: &storage.RootFSStorageSnapshot{
					Name: ctr.Driver,
				},
			},
		}

		// Additional information only applies to graphDrivers, so we're done.
		return inspectResponse, macAddress, nil
	}

	inspectResponse.GraphDriver = &storage.DriverData{
		Name: ctr.Driver,
	}
	if ctr.RWLayer == nil {
		if ctr.State.Dead {
			return inspectResponse, "", nil
		}
		return nil, "", errdefs.System(errors.New("RWLayer of container " + ctr.ID + " is unexpectedly nil"))
	}

	graphDriverData, err := ctr.RWLayer.Metadata()
	if err != nil {
		if ctr.State.Dead {
			// container is marked as Dead, and its graphDriver metadata may
			// have been removed; we can ignore errors.
			return inspectResponse, "", nil
		}
		return nil, "", errdefs.System(err)
	}

	inspectResponse.GraphDriver.Data = graphDriverData
	return inspectResponse, macAddress, nil
}

// ContainerExecInspect returns low-level information about the exec
// command. An error is returned if the exec cannot be found.
func (daemon *Daemon) ContainerExecInspect(id string) (*containertypes.ExecInspectResponse, error) {
	e := daemon.execCommands.Get(id)
	if e == nil {
		return nil, errExecNotFound(id)
	}

Review comment (suggestion):
I think we should still return the configured MAC address in this case - and ditto for line 185?

It'd previously have been assigned to `ctr.Config.MacAddress`, which ends up in the response. (And it's config, not running state.)

Code after:
		HostConfig:   &hostConfig,
		Config:       ctr.Config,
	}

	// Now set any platform-specific fields
	inspectResponse = setPlatformSpecificContainerFields(ctr, inspectResponse)

	if daemon.UsesSnapshotter() {
		inspectResponse.Storage = &storage.Storage{
			RootFS: &storage.RootFSStorage{
				Snapshot: &storage.RootFSStorageSnapshot{
					Name: ctr.Driver,
				},
			},
		}

		// Additional information only applies to graphDrivers, so we're done.
		return inspectResponse, macAddress, nil
	}

	inspectResponse.GraphDriver = &storage.DriverData{
		Name: ctr.Driver,
	}
	if ctr.RWLayer == nil {
		if ctr.State.Dead {
			return inspectResponse, macAddress, nil
		}
		return nil, "", errdefs.System(errors.New("RWLayer of container " + ctr.ID + " is unexpectedly nil"))
	}

	graphDriverData, err := ctr.RWLayer.Metadata()
	if err != nil {
		if ctr.State.Dead {
			// container is marked as Dead, and its graphDriver metadata may
			// have been removed; we can ignore errors.
			return inspectResponse, macAddress, nil
		}
		return nil, "", errdefs.System(err)
	}

	inspectResponse.GraphDriver.Data = graphDriverData
	return inspectResponse, macAddress, nil
}

// ContainerExecInspect returns low-level information about the exec
// command. An error is returned if the exec cannot be found.
func (daemon *Daemon) ContainerExecInspect(id string) (*containertypes.ExecInspectResponse, error) {
	e := daemon.execCommands.Get(id)
	if e == nil {
		return nil, errExecNotFound(id)
	}