Skip to content

Commit

Permalink
Merge pull request #3 from 0x5d/rpk-fix-local-img-lookup
Browse files Browse the repository at this point in the history
rpk/container: Fix local image lookup
  • Loading branch information
Alexander Gallego committed Nov 4, 2020
2 parents 8552cbe + fb44151 commit fa1df02
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/go/rpk/pkg/cli/cmd/container/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
)

const (
redpandaNetwork = "redpanda"
redpandaImage = "docker.io/vectorized/redpanda"
redpandaNetwork = "redpanda"
registry = "docker.io"
redpandaImageBase = "vectorized/redpanda"
redpandaImage = registry + "/" + redpandaImageBase

defaultDockerClientTimeout = 10 * time.Second
)
Expand Down Expand Up @@ -213,9 +215,8 @@ func CreateNode(
}
hostname := Name(nodeID)
containerConfig := container.Config{
Image: redpandaImage,
Image: redpandaImageBase,
Hostname: hostname,
User: "redpanda",
ExposedPorts: nat.PortSet{
rPort: {},
kPort: {},
Expand Down Expand Up @@ -306,16 +307,16 @@ func PullImage(c Client) error {

func CheckIfImgPresent(c Client) (bool, error) {
ctx, _ := DefaultCtx()
imgs, err := c.ImageList(ctx, types.ImageListOptions{})
filters := filters.NewArgs(
filters.Arg("reference", redpandaImageBase),
)
imgs, err := c.ImageList(ctx, types.ImageListOptions{
Filters: filters,
})
if err != nil {
return false, err
}
for _, img := range imgs {
if img.ID == redpandaImage {
return true, nil
}
}
return false, nil
return len(imgs) > 0, nil
}

func getHostPort(
Expand Down

0 comments on commit fa1df02

Please sign in to comment.