@@ -26,7 +26,9 @@ import (
2626 "github.com/projectatomic/libpod/libpod/common"
2727 "github.com/projectatomic/libpod/libpod/driver"
2828 "github.com/projectatomic/libpod/pkg/inspect"
29+ "github.com/projectatomic/libpod/pkg/registries"
2930 "github.com/projectatomic/libpod/pkg/util"
31+ "github.com/sirupsen/logrus"
3032)
3133
3234// imageConversions is used to cache image "cast" types
@@ -426,7 +428,7 @@ func (i *Image) UntagImage(tag string) error {
426428}
427429
428430// PushImage pushes the given image to a location described by the given path
429- func (i * Image ) PushImage (ctx context.Context , destination , manifestMIMEType , authFile , signaturePolicyPath string , writer io.Writer , forceCompress bool , signingOptions SigningOptions , dockerRegistryOptions * DockerRegistryOptions ) error {
431+ func (i * Image ) PushImage (ctx context.Context , destination , manifestMIMEType , authFile , signaturePolicyPath string , writer io.Writer , forceCompress bool , signingOptions SigningOptions , dockerRegistryOptions * DockerRegistryOptions , forceSecure bool ) error {
430432 if destination == "" {
431433 return errors .Wrapf (syscall .EINVAL , "destination image name must be specified" )
432434 }
@@ -458,9 +460,23 @@ func (i *Image) PushImage(ctx context.Context, destination, manifestMIMEType, au
458460 if err != nil {
459461 return errors .Wrapf (err , "error getting source imageReference for %q" , i .InputName )
460462 }
461-
463+ insecureRegistries , err := registries .GetInsecureRegistries ()
464+ if err != nil {
465+ return err
466+ }
462467 copyOptions := getCopyOptions (writer , signaturePolicyPath , nil , dockerRegistryOptions , signingOptions , authFile , manifestMIMEType , forceCompress )
468+ if strings .HasPrefix (DockerTransport , dest .Transport ().Name ()) {
469+ imgRef , err := reference .Parse (dest .DockerReference ().String ())
470+ if err != nil {
471+ return err
472+ }
473+ registry := reference .Domain (imgRef .(reference.Named ))
463474
475+ if util .StringInSlice (registry , insecureRegistries ) && ! forceSecure {
476+ copyOptions .DestinationCtx .DockerInsecureSkipTLSVerify = true
477+ logrus .Info (fmt .Sprintf ("%s is an insecure registry; pushing with tls-verify=false" , registry ))
478+ }
479+ }
464480 // Copy the image to the remote destination
465481 err = cp .Image (ctx , policyContext , dest , src , copyOptions )
466482 if err != nil {
0 commit comments