Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container config to compat image inspect #10893

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions pkg/api/handlers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,32 @@ func ImageDataToImageInspect(ctx context.Context, l *libimage.Image) (*ImageInsp
Name: info.GraphDriver.Name,
Data: info.GraphDriver.Data,
}
// Add in basic ContainerConfig to satisfy docker-compose
cc := new(dockerContainer.Config)
cc.Hostname = info.ID[0:11] // short ID is the hostname
cc.Volumes = info.Config.Volumes

dockerImageInspect := docker.ImageInspect{
Architecture: info.Architecture,
Author: info.Author,
Comment: info.Comment,
Config: &config,
Created: l.Created().Format(time.RFC3339Nano),
DockerVersion: info.Version,
GraphDriver: graphDriver,
ID: "sha256:" + l.ID(),
Metadata: docker.ImageMetadata{},
Os: info.Os,
OsVersion: info.Version,
Parent: info.Parent,
RepoDigests: info.RepoDigests,
RepoTags: info.RepoTags,
RootFS: rootfs,
Size: info.Size,
Variant: "",
VirtualSize: info.VirtualSize,
Architecture: info.Architecture,
Author: info.Author,
Comment: info.Comment,
Config: &config,
ContainerConfig: cc,
Created: l.Created().Format(time.RFC3339Nano),
DockerVersion: info.Version,
GraphDriver: graphDriver,
ID: "sha256:" + l.ID(),
Metadata: docker.ImageMetadata{},
Os: info.Os,
OsVersion: info.Version,
Parent: info.Parent,
RepoDigests: info.RepoDigests,
RepoTags: info.RepoTags,
RootFS: rootfs,
Size: info.Size,
Variant: "",
VirtualSize: info.VirtualSize,
}
// TODO: consider filling the container config.
return &ImageInspect{dockerImageInspect}, nil
}

Expand Down
2 changes: 2 additions & 0 deletions test/compose/uptwice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM alpine
WORKDIR /app
5 changes: 5 additions & 0 deletions test/compose/uptwice/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '3'
services:
app:
build: .
command: sleep 10002
4 changes: 4 additions & 0 deletions test/compose/uptwice/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- bash -*-

sed -i -e 's/10001/10002/' docker-compose.yml
docker-compose up -d