Home > Net >  docker-compose version 3 doesn't recognize runtime
docker-compose version 3 doesn't recognize runtime

Time:10-28

I met the following issue that compose file

version: '3'

services:
  minkowski:
    build:
      context: .
      dockerfile: DockerfileGPU
    volumes:
      - "../:/app:rw"
      - "${DATA_PATH}:/app/data:rw"
    working_dir: /app
    tty: true
    stdin_open: true
    network_mode: "host"
    runtime: nvidia

results in

ERROR: The Compose file './docker/compose-gpu.yaml' is invalid because:
services.minkowski.build contains unsupported option: 'runtime'

I have docker version 20.10.21 and docker-compose 1.25.0. Do you have any idea why that happens?

I tried use different versions. Running

sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi

works fine

CodePudding user response:

The runtime: option isn't supported in Compose file version 3; it is only in version 2. More broadly, current versions of Compose support both Compose file versions 2 and 3, and it's okay to use either. Version 3's options are more oriented towards the Swarm orchestrator and for some single-host-specific options like this you need to use version 2.

version: '2.4' # not 3.x
services:
  ...:
    runtime: nvidia

The newer Compose Specification also supports runtime: but support for this is inconsistent across Compose versions. The Compose 1.25.0 you mention will not support it. That doesn't suggest specific values for version:, and I might label a file as version: '4.0' if you're using Compose Specification specific functionality.

CodePudding user response:

I managed to fix the issue by installing the newer docker compose. With docker compose 2.x it works just fine, without further changes

  • Related