Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose v2 support in local mode #4038

Closed
sateeshmannar opened this issue Jul 31, 2023 · 4 comments · Fixed by #4111
Closed

Docker compose v2 support in local mode #4038

sateeshmannar opened this issue Jul 31, 2023 · 4 comments · Fixed by #4111
Labels

Comments

@sateeshmannar
Copy link

Describe the bug
Local mode execution currently just uses "docker-compose" and dosen't use the newer "docker compose".
The _compose function @ image,py should attempt to find both docker compose executables and use the one thats available with v2 (docker compose) being the first option.

relevant code to change:

# check if docker-compose is installed
if find_executable("docker-compose") is None:
raise ImportError(
"'docker-compose' is not installed. "
"Local Mode features will not work without docker-compose. "
"For more information on how to install 'docker-compose', please, see "
"https://docs.docker.com/compose/install/"
)

def _compose(self, detached=False):
"""Invokes the docker compose command.
Args:
detached:
"""
compose_cmd = "docker-compose"
command = [
compose_cmd,
"-f",
os.path.join(self.container_root, DOCKER_COMPOSE_FILENAME),
"up",
"--build",
"--abort-on-container-exit" if not detached else "--detach", # mutually exclusive
]
logger.info("docker command: %s", " ".join(command))
return command

To reproduce
Install the latest version of SageMaker SDK and attempt to run a processing or training task in local mode.

  • Run local mode WITHOUT installing package "docker-compose" (docker-compose 1.29.2)

Expected behavior
local mode execution should attempt to find both docker compose executables ("docker compose" , "docker-compose" in the listed order) and use the one thats available. "docker compose" the newer version should be the preferred option if both executables are found in the runtime environment.

System information

  • SageMaker Python SDK version: 2.173.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): SageMaker Processing
  • Python version: 3.11.4
  • CPU or GPU: CPU
  • Custom Docker image (Y/N): Yes

Additional context
The custom docker image was working in local mode until the dependency package (docker-compose 1.29.2) was removed local requirements as part of release v2.164.0

@lorenzwalthert
Copy link

Also see #3613.

@jmahlik
Copy link
Contributor

jmahlik commented Aug 3, 2023

In case anyone runs in to this, depending how docker compose is installed one has to add a shim for docker-compose after installing compose v2. Mostly when it's installed via a package manager (the recommended way to install so it's updatable). #3913 doesn't really call this out.

It would be ideal if the sdk could find the new executable to avoid the shim. Users could install compose as normal then.

Right now it looks like below. We could remove the shim if the sdk found docker compose.

 sudo yum install -y yum-utils
 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# We have to add this script
cat << EOF | sudo tee /usr/local/bin/docker-compose
#!/bin/bash
docker compose --compatibility "\$@"
EOF
chmod +x  /usr/local/bin/docker-compose

@Ce11an
Copy link

Ce11an commented Aug 17, 2023

Any movement on this? I have tried several different methods in my CI pipeline to no avail.

@jmahlik
Copy link
Contributor

jmahlik commented Aug 18, 2023

Any movement on this? I have tried several different methods in my CI pipeline to no avail.

What kind of issues are you running in to? Do you have a traceback? Did you add a shim in to map compose to docker-compose or directly download the binary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants