mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
Use 'docker compose' by default
We now fall back to 'docker-compose' if need be
This commit is contained in:
parent
4f375bbf36
commit
df6c8c196e
5 changed files with 21 additions and 20 deletions
|
|
@ -296,12 +296,6 @@ By default we only show logs from the last hour, so that we're not putting too m
|
|||
|
||||
If you are running lazydocker in Docker container, it is a know bug, that you can't see logs or CPU usage.
|
||||
|
||||
### Why isn't my docker-compose environment being used?
|
||||
|
||||
By default Compose V1 (`docker-compose` with the hyphen) is used as the docker-compose command. You will need to make sure you have the `docker-compose` command available for lazydocker to be able to use.
|
||||
|
||||
If you use Compose V2 (`docker compose` without the hyphen), alternatively, you can change the docker-compose command used via the `commandTemplates.dockerCompose` config value.
|
||||
|
||||
## Alternatives
|
||||
|
||||
- [docui](https://github.com/skanehira/docui) - Skanehira beat me to the punch on making a docker terminal UI, so definitely check out that repo as well! I think the two repos can live in harmony though: lazydocker is more about managing existing containers/services, and docui is more about creating and configuring them.
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ logs:
|
|||
since: '60m' # set to '' to show all logs
|
||||
tail: '' # set to 200 to show last 200 lines of logs
|
||||
commandTemplates:
|
||||
dockerCompose: docker-compose # Determines the Docker Compose command to run, referred to as .DockerCompose in commandTemplates
|
||||
dockerCompose: docker compose # Determines the Docker Compose command to run, referred to as .DockerCompose in commandTemplates
|
||||
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
||||
up: '{{ .DockerCompose }} up -d'
|
||||
down: '{{ .DockerCompose }} down'
|
||||
|
|
|
|||
|
|
@ -113,12 +113,7 @@ func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Translat
|
|||
Closers: []io.Closer{tunnelCloser},
|
||||
}
|
||||
|
||||
command := utils.ApplyTemplate(
|
||||
config.UserConfig.CommandTemplates.CheckDockerComposeConfig,
|
||||
dockerCommand.NewCommandObject(CommandObject{}),
|
||||
)
|
||||
|
||||
log.Warn(command)
|
||||
dockerCommand.setDockerComposeCommand(config)
|
||||
|
||||
err = osCommand.RunCommand(
|
||||
utils.ApplyTemplate(
|
||||
|
|
@ -134,6 +129,18 @@ func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Translat
|
|||
return dockerCommand, nil
|
||||
}
|
||||
|
||||
func (c *DockerCommand) setDockerComposeCommand(config *config.AppConfig) {
|
||||
if config.UserConfig.CommandTemplates.DockerCompose != "docker compose" {
|
||||
return
|
||||
}
|
||||
|
||||
// it's possible that a user is still using docker-compose, so we'll check if 'docker comopose' is available, and if not, we'll fall back to 'docker-compose'
|
||||
err := c.OSCommand.RunCommand("docker compose version")
|
||||
if err != nil {
|
||||
config.UserConfig.CommandTemplates.DockerCompose = "docker-compose"
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DockerCommand) Close() error {
|
||||
return utils.CloseMany(c.Closers)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ type CommandTemplatesConfig struct {
|
|||
|
||||
// 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
|
||||
// this to "docker-compose -f foo/docker-compose.yml -f
|
||||
// this to "docker compose -f foo/docker-compose.yml -f
|
||||
// bah/docker-compose.yml". The reason that the other docker-compose command
|
||||
// templates all start with {{ .DockerCompose }} is so that they can make use
|
||||
// of whatever you've set in this value rather than you having to copy and
|
||||
|
|
@ -200,7 +200,7 @@ type CommandTemplatesConfig struct {
|
|||
// and ensure they're running before trying to run the service at hand
|
||||
RecreateService string `yaml:"recreateService,omitempty"`
|
||||
|
||||
// AllLogs is for showing what you get from doing `docker-compose logs`. It
|
||||
// AllLogs is for showing what you get from doing `docker compose logs`. It
|
||||
// combines all the logs together
|
||||
AllLogs string `yaml:"allLogs,omitempty"`
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ func GetDefaultConfig() UserConfig {
|
|||
Tail: "",
|
||||
},
|
||||
CommandTemplates: CommandTemplatesConfig{
|
||||
DockerCompose: "docker-compose",
|
||||
DockerCompose: "docker compose",
|
||||
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
||||
StartService: "{{ .DockerCompose }} start {{ .Service.Name }}",
|
||||
Up: "{{ .DockerCompose }} up -d",
|
||||
|
|
@ -502,7 +502,7 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Pass compose files as individual -f flags to docker-compose
|
||||
// Pass compose files as individual -f flags to docker compose
|
||||
if len(composeFiles) > 0 {
|
||||
userConfig.CommandTemplates.DockerCompose += " -f " + strings.Join(composeFiles, " -f ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestDockerComposeCommandNoFiles(t *testing.T) {
|
|||
}
|
||||
|
||||
actual := conf.UserConfig.CommandTemplates.DockerCompose
|
||||
expected := "docker-compose"
|
||||
expected := "docker compose"
|
||||
if actual != expected {
|
||||
t.Fatalf("Expected %s but got %s", expected, actual)
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ func TestDockerComposeCommandSingleFile(t *testing.T) {
|
|||
}
|
||||
|
||||
actual := conf.UserConfig.CommandTemplates.DockerCompose
|
||||
expected := "docker-compose -f one.yml"
|
||||
expected := "docker compose -f one.yml"
|
||||
if actual != expected {
|
||||
t.Fatalf("Expected %s but got %s", expected, actual)
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ func TestDockerComposeCommandMultipleFiles(t *testing.T) {
|
|||
}
|
||||
|
||||
actual := conf.UserConfig.CommandTemplates.DockerCompose
|
||||
expected := "docker-compose -f one.yml -f two.yml -f three.yml"
|
||||
expected := "docker compose -f one.yml -f two.yml -f three.yml"
|
||||
if actual != expected {
|
||||
t.Fatalf("Expected %s but got %s", expected, actual)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue