Start a container by Docker.DotNet using DockerCompose with --comaptibility flag

443 Views Asked by At

I have a dockerCompose yaml file in version 3.8 with some setting to limit the memory of the container. Because I don't use swarm, I should use the --compatibility flag to make it working. I use this command and worked correctly by using docker cli.

My docker compose yaml:

version: '3.8'
services:
  db:    
    image: "xxxxx:yyyy"
    ports:
      - "10001:22"
    volumes: 
      - "C:/Shared:C:/Data/"
    deploy:
      resources:
        limits:
          memory: 1500m

Code to start container:

docker compose -f "C:\Temp\limit_compose2.yml" --compatibility up

I don't know how it could be possible to do it with Docker.DotNet?

I'm currently using Docker.DotNet 3.125.5 and start container like the following:

//filled containerParameters from docker compose yaml before and using it here

var containerCreateResult = client.Containers.CreateContainerAsync(containerParameter).Result;
var containerStartParameter = new ContainerStartParameters() { };
var startContainerResult = client.Containers.StartContainerAsync(containerCreateResult.ID, containerStartParameter).Result;
0

There are 0 best solutions below