diff --git a/api/docker/snapshot.go b/api/docker/snapshot.go index 9cb337df6..a6e090a65 100644 --- a/api/docker/snapshot.go +++ b/api/docker/snapshot.go @@ -220,7 +220,9 @@ func snapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Client) snapshot.HealthyContainerCount = healthyContainers snapshot.UnhealthyContainerCount = unhealthyContainers snapshot.StackCount += len(stacks) - snapshot.SnapshotRaw.Containers = containers + for _, container := range containers { + snapshot.SnapshotRaw.Containers = append(snapshot.SnapshotRaw.Containers, portainer.DockerContainerSnapshot{Container: container}) + } return nil } diff --git a/api/portainer.go b/api/portainer.go index cd4e2f33e..e78af4067 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -207,15 +207,21 @@ type ( GpuUseList []string `json:"GpuUseList"` } - // DockerSnapshotRaw represents all the information related to a snapshot as returned by the Docker API + // DockerContainerSnapshot is an extent of Docker's Container struct + // It contains some information of Docker's ContainerJSON struct + DockerContainerSnapshot struct { + types.Container + Env []string `json:"Env"` + } + // DockerSnapshotRaw represents all the information related to a snapshot as returned by the Docker API DockerSnapshotRaw struct { - Containers []types.Container `json:"Containers" swaggerignore:"true"` - Volumes volume.VolumeListOKBody `json:"Volumes" swaggerignore:"true"` - Networks []types.NetworkResource `json:"Networks" swaggerignore:"true"` - Images []types.ImageSummary `json:"Images" swaggerignore:"true"` - Info types.Info `json:"Info" swaggerignore:"true"` - Version types.Version `json:"Version" swaggerignore:"true"` + Containers []DockerContainerSnapshot `json:"Containers" swaggerignore:"true"` + Volumes volume.VolumeListOKBody `json:"Volumes" swaggerignore:"true"` + Networks []types.NetworkResource `json:"Networks" swaggerignore:"true"` + Images []types.ImageSummary `json:"Images" swaggerignore:"true"` + Info types.Info `json:"Info" swaggerignore:"true"` + Version types.Version `json:"Version" swaggerignore:"true"` } // EdgeGroup represents an Edge group diff --git a/app/react/docker/snapshots/types/index.ts b/app/react/docker/snapshots/types/index.ts index acb169a4c..185a57e90 100644 --- a/app/react/docker/snapshots/types/index.ts +++ b/app/react/docker/snapshots/types/index.ts @@ -1,7 +1,11 @@ import { DockerContainer } from '@/react/docker/containers/types'; +export type DockerContainerSnapshot = DockerContainer & { + Env?: string[]; +}; + export type DockerSnapshotRaw = { - Containers: DockerContainer[]; + Containers: DockerContainerSnapshot[]; SnapshotTime: string; };