lazydocker icon indicating copy to clipboard operation
lazydocker copied to clipboard

Allow tagging, pushing, and pulling images

Open jesseduffield opened this issue 3 years ago • 20 comments

Is your feature request related to a problem? Please describe. It would be good if we could tag, push, and pull images from the images panel.

Describe the solution you'd like

  • In the images panel when you press 't' it should bring up an input prompt for you to enter a tag and then upon pressing enter it should tag the selected image with that tag.
  • When you press 'p' it should bring up a prompt to enter an and tag in the form "image:tag" to pull
  • When you press 'P' it should push the current image, with a confirmation asking if you're sure you want to

Describe alternatives you've considered The pull feature would benefit from actually trying to search dockerhub, but we can leave that for another PR.

Additional context the 'p', 'P' thing will be familiar for people who use lazygit

jesseduffield avatar Oct 25 '22 19:10 jesseduffield

@jesseduffield , for pushing the image, how would the authentication be perfomed, or is it like already been taken care of, if yes, where?

26tanishabanik avatar Nov 28 '22 19:11 26tanishabanik

good question. To my knowledge, docker wouldn't ask you to for a password upon trying to push, it would just fail if you're not already logged into the registry. I'm happy for a login flow to be handled in a separate issue

jesseduffield avatar Nov 28 '22 23:11 jesseduffield

good question. To my knowledge, docker wouldn't ask you to for a password upon trying to push, it would just fail if you're not already logged into the registry. I'm happy for a login flow to be handled in a separate issue

Understood. So, which part of this issue can I work on and where should I start for that in the source code?

26tanishabanik avatar Nov 29 '22 07:11 26tanishabanik

All three of the keybindings (tagging, pushing, pulling)

  • the keybindings need to be set in pkg/gui/keybindings.go
  • the handlers for the keybindings need to be created in pkg/gui/images_panel.go

jesseduffield avatar Nov 29 '22 07:11 jesseduffield

For now, when I press 't' on a selected image, it shows this, with the image name printed on the popUp Panel, but similarly how can I get the input value from the input prompt: Screenshot 2022-12-01 at 12 56 27 AM

26tanishabanik avatar Nov 30 '22 19:11 26tanishabanik

You can use this as an example:

	return gui.createPromptPanel(gui.Tr.CustomCommandTitle, func(g *gocui.Gui, v *gocui.View) error {
		command := gui.trimmedContent(v)
		return gui.runSubprocess(gui.OSCommand.RunCustomCommand(command))
	})

jesseduffield avatar Nov 30 '22 22:11 jesseduffield

command := gui.trimmedContent(v)

Thanks, that helped, @jesseduffield

26tanishabanik avatar Dec 01 '22 07:12 26tanishabanik

Right now, with pull options, after selecting pull out of pull and cancel, it's giving this error. I was trying to pull debain:jessie. I tried docker login also. Screenshot 2022-12-01 at 1 22 01 PM

26tanishabanik avatar Dec 01 '22 07:12 26tanishabanik

@26tanishabanik if you used the string debain:jessie, there's a typo, it's actually debIAn:jessie.

mark2185 avatar Dec 01 '22 08:12 mark2185

@26tanishabanik if you used the string debain:jessie, there's a typo, it's actually debIAn:jessie.

I tried with debain:jessie, @mark2185

26tanishabanik avatar Dec 01 '22 08:12 26tanishabanik

Is someone actively working on this issue, if not I would love to pick this up!

Also I found that ld displays only the first tag in case image is tagged with different tags

....
	for i, image := range images {
		firstTag := ""
		tags := image.RepoTags
		if len(tags) > 0 {
			firstTag = tags[0]
		}
...

is it something that needs to be fixed as users can now tag images

glendsoza avatar Dec 10 '22 16:12 glendsoza

Is someone actively working on this issue, if not I would love to pick this up!

Also I found that ld displays only the first tag in case image is tagged with different tags

....
	for i, image := range images {
		firstTag := ""
		tags := image.RepoTags
		if len(tags) > 0 {
			firstTag = tags[0]
		}
...

is it something that needs to be fixed as users can now tag images

I am currently working on it, @glendsoza

26tanishabanik avatar Dec 10 '22 18:12 26tanishabanik

I see that you've taken on a few different issues @26tanishabanik , if you've got other issues in motion it might be worth handing this one off to @glendsoza

jesseduffield avatar Dec 11 '22 23:12 jesseduffield

I see that you've taken on a few different issues @26tanishabanik , if you've got other issues in motion it might be worth handing this one off to @glendsoza

@jesseduffield , I have almost completed the code actually on all those issues, just waiting for your feedback on the question, I asked about the name:tag. If you want, I can raise a pull request as well

26tanishabanik avatar Dec 12 '22 06:12 26tanishabanik

@26tanishabanik yep go ahead and raise a PR.

In response to your question, you say you used debain:jessie but that itself contains a spelling error. It should be debian:jessie

jesseduffield avatar Dec 12 '22 06:12 jesseduffield

@26tanishabanik yep go ahead and raise a PR.

In response to your question, you say you used debain:jessie but that itself contains a spelling error. It should be debian:jessie

@jesseduffield , I had tried with debian:jessie also, same error, I can show you the screenshots, if you want

26tanishabanik avatar Dec 12 '22 06:12 26tanishabanik

Perhaps raise a PR and then I can pull it down and check it out myself

jesseduffield avatar Dec 12 '22 07:12 jesseduffield

@26tanishabanik the problem is that you're passing the image ID to the ImagePull method, and that starts with sha256, which is why it shows up in the error message.

I was originally thinking the user would type in an image and then pull the image that they typed in, but I see the use case for pulling the selected image (and tag). Taking a look at docker desktop, it shows images on a per-tag basis, so we should do the same thing i.e. if an image has two separate tags, there should be two entries in the images panel. You can find the code for that in pkg/commands/image.go RefreshImages().

So with that approach, we can now make it so that when you hit 'p' on an image it brings up a confirmation confirming that you want to pull : again.

We can do the same thing with pushing.

As for tagging, we should actually have two prompts: one for the image name, and one for the image tag. The image name option can be pre-populated with the existing image name.

For pulling, we could have extra functionality that allows you to actually enter the name of the image you want to pull, but I'm happy to have a separate issue for that.

jesseduffield avatar Dec 13 '22 08:12 jesseduffield

@26tanishabanik the problem is that you're passing the image ID to the ImagePull method, and that starts with sha256, which is why it shows up in the error message.

I was originally thinking the user would type in an image and then pull the image that they typed in, but I see the use case for pulling the selected image (and tag). Taking a look at docker desktop, it shows images on a per-tag basis, so we should do the same thing i.e. if an image has two separate tags, there should be two entries in the images panel. You can find the code for that in pkg/commands/image.go RefreshImages().

So with that approach, we can now make it so that when you hit 'p' on an image it brings up a confirmation confirming that you want to pull : again.

We can do the same thing with pushing.

As for tagging, we should actually have two prompts: one for the image name, and one for the image tag. The image name option can be pre-populated with the existing image name.

For pulling, we could have extra functionality that allows you to actually enter the name of the image you want to pull, but I'm happy to have a separate issue for that.

@jesseduffield , if an image is present already, then why to pull it again? Pushing is fine, I understood I tagging, why not take the image and tag in the form of image:tag in one prompt?

26tanishabanik avatar Dec 13 '22 15:12 26tanishabanik

You might want to pull again if dealing with an immutable tag like 'latest'

I'm happy with the image:tag approach in one prompt.

jesseduffield avatar Jan 03 '23 22:01 jesseduffield