mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 16:11:04 +00:00
Merge pull request #338 from jesseduffield/no-more-docker
This commit is contained in:
commit
7396dcb0b7
9 changed files with 179 additions and 116 deletions
|
|
@ -34,6 +34,7 @@ logs:
|
||||||
commandTemplates:
|
commandTemplates:
|
||||||
dockerCompose: docker-compose
|
dockerCompose: docker-compose
|
||||||
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
||||||
|
startService: '{{ .DockerCompose }} start {{ .Service.Name }}'
|
||||||
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
||||||
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
||||||
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
||||||
|
|
@ -46,12 +47,6 @@ commandTemplates:
|
||||||
dockerComposeConfig: '{{ .DockerCompose }} config'
|
dockerComposeConfig: '{{ .DockerCompose }} config'
|
||||||
checkDockerComposeConfig: '{{ .DockerCompose }} config --quiet'
|
checkDockerComposeConfig: '{{ .DockerCompose }} config --quiet'
|
||||||
serviceTop: '{{ .DockerCompose }} top {{ .Service.Name }}'
|
serviceTop: '{{ .DockerCompose }} top {{ .Service.Name }}'
|
||||||
customCommands:
|
|
||||||
containers:
|
|
||||||
- name: bash
|
|
||||||
attach: true
|
|
||||||
command: "docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'"
|
|
||||||
serviceNames: []
|
|
||||||
oS:
|
oS:
|
||||||
openCommand: open {{filename}}
|
openCommand: open {{filename}}
|
||||||
openLinkCommand: open {{link}}
|
openLinkCommand: open {{link}}
|
||||||
|
|
@ -84,3 +79,16 @@ The available attributes are:
|
||||||
- bold
|
- bold
|
||||||
- reverse # useful for high-contrast
|
- reverse # useful for high-contrast
|
||||||
- underline
|
- underline
|
||||||
|
|
||||||
|
## Custom Commands
|
||||||
|
|
||||||
|
You can add custom commands like so:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
customCommands:
|
||||||
|
containers:
|
||||||
|
- name: bash
|
||||||
|
attach: true
|
||||||
|
command: 'docker exec -it {{ .Container.ID }} bash'
|
||||||
|
serviceNames: []
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ func (c *Container) Attach() (*exec.Cmd, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Log.Warn(fmt.Sprintf("attaching to container %s", c.Name))
|
c.Log.Warn(fmt.Sprintf("attaching to container %s", c.Name))
|
||||||
|
// TODO: use SDK
|
||||||
cmd := c.OSCommand.PrepareSubProcess("docker", "attach", "--sig-proxy=false", c.ID)
|
cmd := c.OSCommand.PrepareSubProcess("docker", "attach", "--sig-proxy=false", c.ID)
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,16 @@ func (s *Service) Restart() error {
|
||||||
return s.OSCommand.RunCommand(command)
|
return s.OSCommand.RunCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restart starts the service
|
||||||
|
func (s *Service) Start() error {
|
||||||
|
templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StartService
|
||||||
|
command := utils.ApplyTemplate(
|
||||||
|
templateString,
|
||||||
|
s.DockerCommand.NewCommandObject(CommandObject{Service: s}),
|
||||||
|
)
|
||||||
|
return s.OSCommand.RunCommand(command)
|
||||||
|
}
|
||||||
|
|
||||||
// Attach attaches to the service
|
// Attach attaches to the service
|
||||||
func (s *Service) Attach() (*exec.Cmd, error) {
|
func (s *Service) Attach() (*exec.Cmd, error) {
|
||||||
return s.Container.Attach()
|
return s.Container.Attach()
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,9 @@ type CommandTemplatesConfig struct {
|
||||||
// .Service.Name }}
|
// .Service.Name }}
|
||||||
RestartService string `yaml:"restartService,omitempty"`
|
RestartService string `yaml:"restartService,omitempty"`
|
||||||
|
|
||||||
|
// StartService is just like the above but for starting
|
||||||
|
StartService string `yaml:"startService,omitempty"`
|
||||||
|
|
||||||
// DockerCompose is for your docker-compose command. You may want to combine a
|
// DockerCompose is for your docker-compose command. You may want to combine a
|
||||||
// few different docker-compose.yml files together, in which case you can set
|
// few different docker-compose.yml files together, in which case you can set
|
||||||
// this to "docker-compose -f foo/docker-compose.yml -f
|
// this to "docker-compose -f foo/docker-compose.yml -f
|
||||||
|
|
@ -326,6 +329,7 @@ func GetDefaultConfig() UserConfig {
|
||||||
CommandTemplates: CommandTemplatesConfig{
|
CommandTemplates: CommandTemplatesConfig{
|
||||||
DockerCompose: "docker-compose",
|
DockerCompose: "docker-compose",
|
||||||
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
||||||
|
StartService: "{{ .DockerCompose }} start {{ .Service.Name }}",
|
||||||
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
||||||
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
||||||
StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}",
|
StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}",
|
||||||
|
|
@ -336,19 +340,14 @@ func GetDefaultConfig() UserConfig {
|
||||||
DockerComposeConfig: "{{ .DockerCompose }} config",
|
DockerComposeConfig: "{{ .DockerCompose }} config",
|
||||||
CheckDockerComposeConfig: "{{ .DockerCompose }} config --quiet",
|
CheckDockerComposeConfig: "{{ .DockerCompose }} config --quiet",
|
||||||
ServiceTop: "{{ .DockerCompose }} top {{ .Service.Name }}",
|
ServiceTop: "{{ .DockerCompose }} top {{ .Service.Name }}",
|
||||||
ViewContainerLogs: "docker logs --timestamps --follow --since=60m {{ .Container.ID }}",
|
// TODO: use SDK
|
||||||
|
ViewContainerLogs: "docker logs --timestamps --follow --since=60m {{ .Container.ID }}",
|
||||||
},
|
},
|
||||||
CustomCommands: CustomCommands{
|
CustomCommands: CustomCommands{
|
||||||
Containers: []CustomCommand{
|
Containers: []CustomCommand{},
|
||||||
{
|
Services: []CustomCommand{},
|
||||||
Name: "bash",
|
Images: []CustomCommand{},
|
||||||
Command: "docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'",
|
Volumes: []CustomCommand{},
|
||||||
Attach: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Services: []CustomCommand{},
|
|
||||||
Images: []CustomCommand{},
|
|
||||||
Volumes: []CustomCommand{},
|
|
||||||
},
|
},
|
||||||
BulkCommands: CustomCommands{
|
BulkCommands: CustomCommands{
|
||||||
Services: []CustomCommand{
|
Services: []CustomCommand{
|
||||||
|
|
|
||||||
|
|
@ -569,6 +569,8 @@ func (gui *Gui) handleContainersExecShell(g *gocui.Gui, v *gocui.View) error {
|
||||||
commandObject := gui.DockerCommand.NewCommandObject(commands.CommandObject{
|
commandObject := gui.DockerCommand.NewCommandObject(commands.CommandObject{
|
||||||
Container: container,
|
Container: container,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: use SDK
|
||||||
resolvedCommand := utils.ApplyTemplate("docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'", commandObject)
|
resolvedCommand := utils.ApplyTemplate("docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'", commandObject)
|
||||||
// attach and return the subprocess error
|
// attach and return the subprocess error
|
||||||
cmd := gui.OSCommand.ExecutableFromString(resolvedCommand)
|
cmd := gui.OSCommand.ExecutableFromString(resolvedCommand)
|
||||||
|
|
|
||||||
|
|
@ -212,17 +212,30 @@ func (gui *Gui) handleImagesRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
||||||
shortSha := Image.ID[7:17]
|
shortSha := Image.ID[7:17]
|
||||||
|
|
||||||
|
// TODO: have a way of toggling in a menu instead of showing each permutation as a separate menu item
|
||||||
options := []*removeImageOption{
|
options := []*removeImageOption{
|
||||||
{
|
{
|
||||||
description: gui.Tr.Remove,
|
description: gui.Tr.Remove,
|
||||||
command: "docker image rm " + shortSha,
|
command: "docker image rm " + shortSha,
|
||||||
configOptions: types.ImageRemoveOptions{PruneChildren: true},
|
configOptions: types.ImageRemoveOptions{PruneChildren: true, Force: false},
|
||||||
runCommand: true,
|
runCommand: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: gui.Tr.RemoveWithoutPrune,
|
description: gui.Tr.RemoveWithoutPrune,
|
||||||
command: "docker image rm --no-prune " + shortSha,
|
command: "docker image rm --no-prune " + shortSha,
|
||||||
configOptions: types.ImageRemoveOptions{PruneChildren: false},
|
configOptions: types.ImageRemoveOptions{PruneChildren: false, Force: false},
|
||||||
|
runCommand: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: gui.Tr.RemoveWithForce,
|
||||||
|
command: "docker image rm --force " + shortSha,
|
||||||
|
configOptions: types.ImageRemoveOptions{PruneChildren: true, Force: true},
|
||||||
|
runCommand: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: gui.Tr.RemoveWithoutPruneWithForce,
|
||||||
|
command: "docker image rm --no-prune --force " + shortSha,
|
||||||
|
configOptions: types.ImageRemoveOptions{PruneChildren: false, Force: true},
|
||||||
runCommand: true,
|
runCommand: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleServiceRestart,
|
Handler: gui.handleServiceRestart,
|
||||||
Description: gui.Tr.Restart,
|
Description: gui.Tr.Restart,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "services",
|
||||||
|
Key: 'S',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleServiceStart,
|
||||||
|
Description: gui.Tr.Start,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "services",
|
ViewName: "services",
|
||||||
Key: 'a',
|
Key: 'a',
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,21 @@ func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleServiceStart(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
service, err := gui.getSelectedService()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return gui.WithWaitingStatus(gui.Tr.StartingStatus, func() error {
|
||||||
|
if err := service.Start(); err != nil {
|
||||||
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleServiceAttach(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleServiceAttach(g *gocui.Gui, v *gocui.View) error {
|
||||||
service, err := gui.getSelectedService()
|
service, err := gui.getSelectedService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -26,65 +26,69 @@ type TranslationSet struct {
|
||||||
CannotAccessDockerSocketError string
|
CannotAccessDockerSocketError string
|
||||||
CannotKillChildError string
|
CannotKillChildError string
|
||||||
|
|
||||||
Donate string
|
Donate string
|
||||||
Cancel string
|
Cancel string
|
||||||
CustomCommandTitle string
|
CustomCommandTitle string
|
||||||
BulkCommandTitle string
|
BulkCommandTitle string
|
||||||
Remove string
|
Remove string
|
||||||
HideStopped string
|
HideStopped string
|
||||||
ForceRemove string
|
ForceRemove string
|
||||||
RemoveWithVolumes string
|
RemoveWithVolumes string
|
||||||
MustForceToRemoveContainer string
|
MustForceToRemoveContainer string
|
||||||
Confirm string
|
Confirm string
|
||||||
Return string
|
Return string
|
||||||
FocusMain string
|
FocusMain string
|
||||||
StopContainer string
|
StopContainer string
|
||||||
RestartingStatus string
|
RestartingStatus string
|
||||||
StoppingStatus string
|
StartingStatus string
|
||||||
RemovingStatus string
|
StoppingStatus string
|
||||||
RunningCustomCommandStatus string
|
RemovingStatus string
|
||||||
RunningBulkCommandStatus string
|
RunningCustomCommandStatus string
|
||||||
RemoveService string
|
RunningBulkCommandStatus string
|
||||||
Stop string
|
RemoveService string
|
||||||
Restart string
|
Stop string
|
||||||
Rebuild string
|
Restart string
|
||||||
Recreate string
|
Start string
|
||||||
PreviousContext string
|
Rebuild string
|
||||||
NextContext string
|
Recreate string
|
||||||
Attach string
|
PreviousContext string
|
||||||
ViewLogs string
|
NextContext string
|
||||||
ServicesTitle string
|
Attach string
|
||||||
ContainersTitle string
|
ViewLogs string
|
||||||
StandaloneContainersTitle string
|
ServicesTitle string
|
||||||
TopTitle string
|
ContainersTitle string
|
||||||
ImagesTitle string
|
StandaloneContainersTitle string
|
||||||
VolumesTitle string
|
TopTitle string
|
||||||
NoContainers string
|
ImagesTitle string
|
||||||
NoContainer string
|
VolumesTitle string
|
||||||
NoImages string
|
NoContainers string
|
||||||
NoVolumes string
|
NoContainer string
|
||||||
RemoveImage string
|
NoImages string
|
||||||
RemoveVolume string
|
NoVolumes string
|
||||||
RemoveWithoutPrune string
|
RemoveImage string
|
||||||
PruneImages string
|
RemoveVolume string
|
||||||
PruneContainers string
|
RemoveWithoutPrune string
|
||||||
PruneVolumes string
|
RemoveWithoutPruneWithForce string
|
||||||
ConfirmPruneContainers string
|
RemoveWithForce string
|
||||||
ConfirmStopContainers string
|
PruneImages string
|
||||||
ConfirmRemoveContainers string
|
PruneContainers string
|
||||||
ConfirmPruneImages string
|
PruneVolumes string
|
||||||
ConfirmPruneVolumes string
|
ConfirmPruneContainers string
|
||||||
PruningStatus string
|
ConfirmStopContainers string
|
||||||
StopService string
|
ConfirmRemoveContainers string
|
||||||
PressEnterToReturn string
|
ConfirmPruneImages string
|
||||||
StopAllContainers string
|
ConfirmPruneVolumes string
|
||||||
RemoveAllContainers string
|
PruningStatus string
|
||||||
ViewRestartOptions string
|
StopService string
|
||||||
ExecShell string
|
PressEnterToReturn string
|
||||||
RunCustomCommand string
|
StopAllContainers string
|
||||||
ViewBulkCommands string
|
RemoveAllContainers string
|
||||||
OpenInBrowser string
|
ViewRestartOptions string
|
||||||
SortContainersByState string
|
ExecShell string
|
||||||
|
RunCustomCommand string
|
||||||
|
ViewBulkCommands string
|
||||||
|
OpenInBrowser string
|
||||||
|
SortContainersByState string
|
||||||
|
|
||||||
LogsTitle string
|
LogsTitle string
|
||||||
ConfigTitle string
|
ConfigTitle string
|
||||||
|
|
@ -106,6 +110,7 @@ func englishSet() TranslationSet {
|
||||||
PruningStatus: "pruning",
|
PruningStatus: "pruning",
|
||||||
RemovingStatus: "removing",
|
RemovingStatus: "removing",
|
||||||
RestartingStatus: "restarting",
|
RestartingStatus: "restarting",
|
||||||
|
StartingStatus: "starting",
|
||||||
StoppingStatus: "stopping",
|
StoppingStatus: "stopping",
|
||||||
RunningCustomCommandStatus: "running custom command",
|
RunningCustomCommandStatus: "running custom command",
|
||||||
RunningBulkCommandStatus: "running bulk command",
|
RunningBulkCommandStatus: "running bulk command",
|
||||||
|
|
@ -124,44 +129,47 @@ func englishSet() TranslationSet {
|
||||||
Donate: "Donate",
|
Donate: "Donate",
|
||||||
Confirm: "Confirm",
|
Confirm: "Confirm",
|
||||||
|
|
||||||
Return: "return",
|
Return: "return",
|
||||||
FocusMain: "focus main panel",
|
FocusMain: "focus main panel",
|
||||||
Navigate: "navigate",
|
Navigate: "navigate",
|
||||||
Execute: "execute",
|
Execute: "execute",
|
||||||
Close: "close",
|
Close: "close",
|
||||||
Menu: "menu",
|
Menu: "menu",
|
||||||
MenuTitle: "Menu",
|
MenuTitle: "Menu",
|
||||||
Scroll: "scroll",
|
Scroll: "scroll",
|
||||||
OpenConfig: "open lazydocker config",
|
OpenConfig: "open lazydocker config",
|
||||||
EditConfig: "edit lazydocker config",
|
EditConfig: "edit lazydocker config",
|
||||||
Cancel: "cancel",
|
Cancel: "cancel",
|
||||||
Remove: "remove",
|
Remove: "remove",
|
||||||
HideStopped: "hide/show stopped containers",
|
HideStopped: "hide/show stopped containers",
|
||||||
ForceRemove: "force remove",
|
ForceRemove: "force remove",
|
||||||
RemoveWithVolumes: "remove with volumes",
|
RemoveWithVolumes: "remove with volumes",
|
||||||
RemoveService: "remove containers",
|
RemoveService: "remove containers",
|
||||||
Stop: "stop",
|
Stop: "stop",
|
||||||
Restart: "restart",
|
Restart: "restart",
|
||||||
Rebuild: "rebuild",
|
Start: "start",
|
||||||
Recreate: "recreate",
|
Rebuild: "rebuild",
|
||||||
PreviousContext: "previous tab",
|
Recreate: "recreate",
|
||||||
NextContext: "next tab",
|
PreviousContext: "previous tab",
|
||||||
Attach: "attach",
|
NextContext: "next tab",
|
||||||
ViewLogs: "view logs",
|
Attach: "attach",
|
||||||
RemoveImage: "remove image",
|
ViewLogs: "view logs",
|
||||||
RemoveVolume: "remove volume",
|
RemoveImage: "remove image",
|
||||||
RemoveWithoutPrune: "remove without deleting untagged parents",
|
RemoveVolume: "remove volume",
|
||||||
PruneContainers: "prune exited containers",
|
RemoveWithoutPrune: "remove without deleting untagged parents",
|
||||||
PruneVolumes: "prune unused volumes",
|
RemoveWithoutPruneWithForce: "remove (forced) without deleting untagged parents",
|
||||||
PruneImages: "prune unused images",
|
RemoveWithForce: "remove (forced)",
|
||||||
StopAllContainers: "stop all containers",
|
PruneContainers: "prune exited containers",
|
||||||
RemoveAllContainers: "remove all containers (forced)",
|
PruneVolumes: "prune unused volumes",
|
||||||
ViewRestartOptions: "view restart options",
|
PruneImages: "prune unused images",
|
||||||
ExecShell: "exec shell",
|
StopAllContainers: "stop all containers",
|
||||||
RunCustomCommand: "run predefined custom command",
|
RemoveAllContainers: "remove all containers (forced)",
|
||||||
ViewBulkCommands: "view bulk commands",
|
ViewRestartOptions: "view restart options",
|
||||||
OpenInBrowser: "open in browser (first port is http)",
|
ExecShell: "exec shell",
|
||||||
SortContainersByState: "sort containers by state",
|
RunCustomCommand: "run predefined custom command",
|
||||||
|
ViewBulkCommands: "view bulk commands",
|
||||||
|
OpenInBrowser: "open in browser (first port is http)",
|
||||||
|
SortContainersByState: "sort containers by state",
|
||||||
|
|
||||||
GlobalTitle: "Global",
|
GlobalTitle: "Global",
|
||||||
MainTitle: "Main",
|
MainTitle: "Main",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue