lazydocker
lazydocker copied to clipboard
Allow tagging, pushing, and pulling images
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 , for pushing the image, how would the authentication be perfomed, or is it like already been taken care of, if yes, where?
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
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?
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
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:

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))
})
command := gui.trimmedContent(v)
Thanks, that helped, @jesseduffield
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.

@26tanishabanik if you used the string debain:jessie, there's a typo, it's actually debIAn:jessie.
@26tanishabanik if you used the string
debain:jessie, there's a typo, it's actuallydebIAn:jessie.
I tried with debain:jessie, @mark2185
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
Is someone actively working on this issue, if not I would love to pick this up!
Also I found that
lddisplays 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
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
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 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
@26tanishabanik yep go ahead and raise a PR.
In response to your question, you say you used
debain:jessiebut that itself contains a spelling error. It should bedebian:jessie
@jesseduffield , I had tried with debian:jessie also, same error, I can show you the screenshots, if you want
Perhaps raise a PR and then I can pull it down and check it out myself
@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
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.
@26tanishabanik the problem is that you're passing the image ID to the
ImagePullmethod, 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.goRefreshImages().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?
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.