diff --git a/Makefile b/Makefile index fe49833d99d1..f979a9d8c66d 100755 --- a/Makefile +++ b/Makefile @@ -572,7 +572,7 @@ out/docker-machine-driver-kvm2-aarch64: out/docker-machine-driver-kvm2-arm64 out/docker-machine-driver-kvm2-%: ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) - docker inspect -f '{{.Id}} {{.RepoTags}}' $(KVM_BUILD_IMAGE) || $(MAKE) kvm-image + docker image inspect -f '{{.Id}} {{.RepoTags}}' $(KVM_BUILD_IMAGE) || $(MAKE) kvm-image $(call DOCKER,$(KVM_BUILD_IMAGE),/usr/bin/make $@ COMMIT=$(COMMIT)) # make extra sure that we are linking with the older version of libvirt (1.3.1) test "`strings $@ | grep '^LIBVIRT_[0-9]' | sort | tail -n 1`" = "LIBVIRT_1.2.9" @@ -619,7 +619,7 @@ kvm-image: installers/linux/kvm/Dockerfile ## Convenient alias to build the doc @echo "$(@) successfully built" kvm_in_docker: - docker inspect -f '{{.Id}} {{.RepoTags}}' $(KVM_BUILD_IMAGE) || $(MAKE) kvm-image + docker image inspect -f '{{.Id}} {{.RepoTags}}' $(KVM_BUILD_IMAGE) || $(MAKE) kvm-image rm -f out/docker-machine-driver-kvm2 $(call DOCKER,$(KVM_BUILD_IMAGE),/usr/bin/make out/docker-machine-driver-kvm2 COMMIT=$(COMMIT)) diff --git a/pkg/drivers/kic/oci/network.go b/pkg/drivers/kic/oci/network.go index 3cb1cf859c70..f39a23f16d63 100644 --- a/pkg/drivers/kic/oci/network.go +++ b/pkg/drivers/kic/oci/network.go @@ -67,7 +67,7 @@ func dockerGatewayIP() (net.IP, error) { } bridgeID := strings.TrimSpace(rr.Stdout.String()) - rr, err = runCmd(exec.Command(Docker, "inspect", + rr, err = runCmd(exec.Command(Docker, "network", "inspect", "--format", "{{(index .IPAM.Config 0).Gateway}}", bridgeID)) if err != nil { return nil, errors.Wrapf(err, "inspect IP bridge network %q.", bridgeID) @@ -80,7 +80,7 @@ func dockerGatewayIP() (net.IP, error) { // containerGatewayIP gets the default gateway ip for the container func containerGatewayIP(ociBin, containerName string) (net.IP, error) { - rr, err := runCmd(exec.Command(ociBin, "inspect", "--format", "{{.NetworkSettings.Gateway}}", containerName)) + rr, err := runCmd(exec.Command(ociBin, "container", "inspect", "--format", "{{.NetworkSettings.Gateway}}", containerName)) if err != nil { return nil, errors.Wrapf(err, "inspect gateway") } @@ -98,13 +98,12 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) { var err error if ociBin == Podman { - //podman inspect -f "{{range .NetworkSettings.Ports}}{{if eq .ContainerPort "80"}}{{.HostPort}}{{end}}{{end}}" - rr, err = runCmd(exec.Command(ociBin, "inspect", "-f", fmt.Sprintf("{{range .NetworkSettings.Ports}}{{if eq .ContainerPort %s}}{{.HostPort}}{{end}}{{end}}", fmt.Sprint(contPort)), ociID)) + rr, err = runCmd(exec.Command(ociBin, "container", "inspect", "-f", fmt.Sprintf("{{range .NetworkSettings.Ports}}{{if eq .ContainerPort %s}}{{.HostPort}}{{end}}{{end}}", fmt.Sprint(contPort)), ociID)) if err != nil { return 0, errors.Wrapf(err, "get port %d for %q", contPort, ociID) } } else { - rr, err = runCmd(exec.Command(ociBin, "inspect", "-f", fmt.Sprintf("'{{(index (index .NetworkSettings.Ports \"%d/tcp\") 0).HostPort}}'", contPort), ociID)) + rr, err = runCmd(exec.Command(ociBin, "container", "inspect", "-f", fmt.Sprintf("'{{(index (index .NetworkSettings.Ports \"%d/tcp\") 0).HostPort}}'", contPort), ociID)) if err != nil { return 0, errors.Wrapf(err, "get port %d for %q", contPort, ociID) } @@ -124,14 +123,14 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) { // ContainerIPs returns ipv4,ipv6, error of a container by their name func ContainerIPs(ociBin string, name string) (string, string, error) { if ociBin == Podman { - return podmanConttainerIP(name) + return podmanContainerIP(name) } return dockerContainerIP(name) } -// podmanConttainerIP returns ipv4, ipv6 of container or error -func podmanConttainerIP(name string) (string, string, error) { - rr, err := runCmd(exec.Command(Podman, "inspect", +// podmanContainerIP returns ipv4, ipv6 of container or error +func podmanContainerIP(name string) (string, string, error) { + rr, err := runCmd(exec.Command(Podman, "container", "inspect", "-f", "{{.NetworkSettings.IPAddress}}", name)) if err != nil { diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 9af2d0ab5ff8..1a1b189cab04 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -277,7 +277,7 @@ func StartContainer(ociBin string, container string) error { // ContainerID returns id of a container name func ContainerID(ociBin string, nameOrID string) (string, error) { - rr, err := runCmd(exec.Command(ociBin, "inspect", "-f", "{{.Id}}", nameOrID)) + rr, err := runCmd(exec.Command(ociBin, "container", "inspect", "-f", "{{.Id}}", nameOrID)) if err != nil { // don't return error if not found, only return empty string if strings.Contains(rr.Stdout.String(), "Error: No such object:") || strings.Contains(rr.Stdout.String(), "unable to find") { err = nil @@ -307,7 +307,7 @@ func ContainerExists(ociBin string, name string, warnSlow ...bool) (bool, error) // IsCreatedByMinikube returns true if the container was created by minikube // with default assumption that it is not created by minikube when we don't know for sure func IsCreatedByMinikube(ociBin string, nameOrID string) bool { - rr, err := runCmd(exec.Command(ociBin, "inspect", nameOrID, "--format", "{{.Config.Labels}}")) + rr, err := runCmd(exec.Command(ociBin, "container", "inspect", nameOrID, "--format", "{{.Config.Labels}}")) if err != nil { return false } @@ -326,7 +326,7 @@ func ListOwnedContainers(ociBin string) ([]string, error) { // inspect return low-level information on containers func inspect(ociBin string, containerNameOrID, format string) ([]string, error) { - cmd := exec.Command(ociBin, "inspect", + cmd := exec.Command(ociBin, "container", "inspect", "-f", format, containerNameOrID) // ... against the "node" container var buff bytes.Buffer @@ -506,7 +506,7 @@ func PointToHostPodman() error { // ContainerRunning returns running state of a container func ContainerRunning(ociBin string, name string, warnSlow ...bool) (bool, error) { - rr, err := runCmd(exec.Command(ociBin, "inspect", name, "--format={{.State.Running}}"), warnSlow...) + rr, err := runCmd(exec.Command(ociBin, "container", "inspect", name, "--format={{.State.Running}}"), warnSlow...) if err != nil { return false, err } @@ -515,7 +515,7 @@ func ContainerRunning(ociBin string, name string, warnSlow ...bool) (bool, error // ContainerStatus returns status of a container running,exited,... func ContainerStatus(ociBin string, name string, warnSlow ...bool) (state.State, error) { - cmd := exec.Command(ociBin, "inspect", name, "--format={{.State.Status}}") + cmd := exec.Command(ociBin, "container", "inspect", name, "--format={{.State.Status}}") rr, err := runCmd(cmd, warnSlow...) o := strings.TrimSpace(rr.Stdout.String()) switch o { diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 8caa5cda972e..d4334dd4f7df 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -136,7 +136,7 @@ func (r *CRIO) Disable() error { // ImageExists checks if an image exists func (r *CRIO) ImageExists(name string, sha string) bool { // expected output looks like [NAME@sha256:SHA] - c := exec.Command("sudo", "podman", "inspect", "--format", "{{.Id}}", name) + c := exec.Command("sudo", "podman", "image", "inspect", "--format", "{{.Id}}", name) rr, err := r.Runner.RunCmd(c) if err != nil { return false diff --git a/pkg/minikube/cruntime/cruntime_test.go b/pkg/minikube/cruntime/cruntime_test.go index c2a5b4324d56..8f5aca6f4735 100644 --- a/pkg/minikube/cruntime/cruntime_test.go +++ b/pkg/minikube/cruntime/cruntime_test.go @@ -267,6 +267,16 @@ func (f *FakeRunner) dockerRm(args []string) (string, error) { return "", nil } +func (f *FakeRunner) dockerInspect(args []string) (string, error) { + if args[1] == "--format" && args[2] == "{{.Id}}" { + if args[3] == "missing" { + return "", &exec.ExitError{Stderr: []byte("Error: No such object: missing")} + } + return "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", nil + } + return "", nil +} + // docker is a fake implementation of docker func (f *FakeRunner) docker(args []string, _ bool) (string, error) { switch cmd := args[0]; cmd { @@ -285,15 +295,14 @@ func (f *FakeRunner) docker(args []string, _ bool) (string, error) { return "18.06.2-ce", nil } - case "inspect": - - if args[1] == "--format" && args[2] == "{{.Id}}" { - if args[3] == "missing" { - return "", &exec.ExitError{Stderr: []byte("Error: No such object: missing")} - } - return "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", nil + case "image": + if args[1] == "inspect" { + return f.dockerInspect(args[1:]) } + case "inspect": + return f.dockerInspect(args) + case "info": if args[1] == "--format" && args[2] == "{{.CgroupDriver}}" { @@ -309,9 +318,9 @@ func (f *FakeRunner) podman(args []string, _ bool) (string, error) { case "--version": return "podman version 1.6.4", nil - case "inspect": + case "image": - if args[1] == "--format" && args[2] == "{{.Id}}" { + if args[1] == "inspect" && args[2] == "--format" && args[3] == "{{.Id}}" { if args[3] == "missing" { return "", &exec.ExitError{Stderr: []byte("Error: error getting image \"missing\": unable to find a name and tag match for missing in repotags: no such image")} } diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 5afd28076510..55e57b3a5373 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -133,7 +133,7 @@ func (r *Docker) Disable() error { // ImageExists checks if an image exists func (r *Docker) ImageExists(name string, sha string) bool { // expected output looks like [SHA_ALGO:SHA] - c := exec.Command("docker", "inspect", "--format", "{{.Id}}", name) + c := exec.Command("docker", "image", "inspect", "--format", "{{.Id}}", name) rr, err := r.Runner.RunCmd(c) if err != nil { return false