Skip to content

Commit

Permalink
Replace docker-compose by 'docker compose'
Browse files Browse the repository at this point in the history
The docker Compose V1 (docker-compose) stopped receiving updates on
July 2023, this PR updates our automation tools to use the new Compose
V2 (docker compose). Compose V2 has been GA since April 2022.

More information on
https://www.docker.com/blog/new-docker-compose-v2-and-v1-deprecation/.
  • Loading branch information
belimawr committed Sep 18, 2024
1 parent 89cd840 commit 37a915c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Debug log entries from the acker (`stateful ack ...` or `stateless ack ...`) removed. {pull}39672[39672]
- Rename x-pack/filebeat websocket input to streaming. {issue}40264[40264] {pull}40421[40421]
- Journald input now calls `journalctl` instead of using `github.com/coreos/go-systemd/[email protected]/sdjournal`, the CGO dependency has been removed from Filebeat {pull}40061[40061]
- Use Docker Compose V2 (`docker compose`) instead of Compose V1 (`docker-compose`) {pull}40890[40890]

==== Bugfixes

Expand Down
6 changes: 3 additions & 3 deletions dev-tools/mage/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ func dockerInfo() (*DockerInfo, error) {
return &info, nil
}

// HaveDockerCompose returns an error if docker-compose is not found on the
// HaveDockerCompose returns an error if docker is not found on the
// PATH.
func HaveDockerCompose() error {
_, err := exec.LookPath("docker-compose")
_, err := exec.LookPath("docker")
if err != nil {
return fmt.Errorf("docker-compose is not available")
return fmt.Errorf("docker is not available")
}
return nil
}
Expand Down
20 changes: 10 additions & 10 deletions dev-tools/mage/integtest_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func (d *DockerIntegrationTester) Test(dir string, mageTarget string, env map[st
composeEnv,
os.Stdout,
os.Stderr,
"docker-compose",
args...,
"docker",
append([]string{"compose"}, args...)...,
)

err = saveDockerComposeLogs(dir, mageTarget)
Expand Down Expand Up @@ -313,8 +313,8 @@ func BuildIntegTestContainers() error {
composeEnv,
out,
os.Stderr,
"docker-compose", args...,
)
"docker",
append([]string{"compose"}, args...)...)

// This sleep is to avoid hitting the docker build issues when resources are not available.
if err != nil {
Expand All @@ -324,8 +324,8 @@ func BuildIntegTestContainers() error {
composeEnv,
out,
os.Stderr,
"docker-compose", args...,
)
"docker",
append([]string{"compose"}, args...)...)
}
return err
}
Expand All @@ -348,8 +348,8 @@ func StartIntegTestContainers() error {
composeEnv,
os.Stdout,
os.Stderr,
"docker-compose",
args...,
"docker",
append([]string{"compose"}, args...)...,
)
return err
}
Expand All @@ -370,7 +370,7 @@ func StopIntegTestContainers() error {
composeEnv,
ioutil.Discard,
out,
"docker-compose",
"docker", "compose",
"-p", DockerComposeProjectName(),
"rm", "--stop", "--force",
)
Expand Down Expand Up @@ -428,7 +428,7 @@ func saveDockerComposeLogs(rootDir string, mageTarget string) error {
composeEnv,
composeLogFile, // stdout
composeLogFile, // stderr
"docker-compose",
"docker", "compose",
"-p", DockerComposeProjectName(),
"logs",
"--no-color",
Expand Down
2 changes: 1 addition & 1 deletion libbeat/tests/compose/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (d *wrapperDriver) cmd(ctx context.Context, command string, arg ...string)
}
args = append(args, command)
args = append(args, arg...)
cmd := exec.CommandContext(ctx, "docker-compose", args...)
cmd := exec.CommandContext(ctx, "docker", append([]string{"compose"}, args...)...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if len(d.Environment) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion testing/environments/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENV?=snapshot.yml
BASE_COMMAND=docker-compose -f ${ENV} -f local.yml
BASE_COMMAND=docker compose -f ${ENV} -f local.yml

start:
# This is run every time to make sure the environment is up-to-date
Expand Down
2 changes: 1 addition & 1 deletion x-pack/winlogbeat/module/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func testIngestPipeline(t *testing.T, pipeline, pattern string, p *params) {
t.Fatal(err)
}
if *wintest.KeepRunning {
fmt.Fprintln(os.Stdout, "Use this to manually cleanup containers: docker-compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
fmt.Fprintln(os.Stdout, "Use this to manually cleanup containers: docker compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
}
t.Cleanup(func() {
stop := !*wintest.KeepRunning
Expand Down
5 changes: 3 additions & 2 deletions x-pack/winlogbeat/module/wintest/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func saveLogs(env map[string]string, root, target string) error {
env,
f, // stdout
f, // stderr
"docker-compose",
"docker", "compose",
"-p", devtools.DockerComposeProjectName(),
"logs",
"--no-color",
Expand Down Expand Up @@ -140,7 +140,8 @@ func dockerCompose(env map[string]string, verbose bool) error {
env,
out,
os.Stderr,
"docker-compose", args...,
"docker",
append([]string{"compose"}, args...)...,
)
if err == nil {
break
Expand Down
2 changes: 1 addition & 1 deletion x-pack/winlogbeat/module/wintest/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestSimulate(t *testing.T) {
t.Fatal(err)
}
if *wintest.KeepRunning {
fmt.Fprintln(os.Stdout, "docker-compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
fmt.Fprintln(os.Stdout, "docker compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
}
t.Cleanup(func() {
stop := !*wintest.KeepRunning
Expand Down

0 comments on commit 37a915c

Please sign in to comment.