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

[Examples] Add docker compose example to run multiple containers #2745

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions examples/docker/compose/compose_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Minimal example using docker compose to run multiple containers
#
# Syncs the docker-compose.yml in the current workdir to the remote cluster and
# runs docker compose up.
#
# Usage:
# sky launch -c myclus compose_example.yaml
# sky down myclus

resources:
accelerators: T4:2

workdir: .

setup: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-compose-plugin

run: |
docker compose -f docker-compose.yml up
24 changes: 24 additions & 0 deletions examples/docker/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
gpu-app1:
image: nvidia/cuda:11.5.2-runtime-ubuntu20.04
command: nvidia-smi # To keep the running in a loop, add -l 1
romilbhardwaj marked this conversation as resolved.
Show resolved Hide resolved
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['0']
capabilities: [gpu]

gpu-app2:
image: nvidia/cuda:11.5.2-runtime-ubuntu20.04
command: nvidia-smi
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['1'] # Allocates GPU ID 1 to this container. Inside the container, this will be visible as device id 0
capabilities: [gpu]