Skip to content

docker run --cpus 2 ... doesn't work #410

@kvinwang

Description

@kvinwang

When running docker run --rm --cpus 2 ubuntu in dstack CVM, it fails with an error:

docker: Error response from daemon: Range of CPUs is from 0.01 to 1.00, as there are only 1 CPUs available.

This is because we have pinned dockerd to only one CPU in Dstack-TEE/meta-dstack#13.
It is unclear what the better solution might be.

Workaround (v0.5.6+)

Add the following to your pre_launch_script to enable --cpus N:

mkdir -p /etc/systemd/system/docker.service.d/
cat > /etc/systemd/system/docker.service.d/override.conf << 'EOF'
[Service]
CPUAffinity=
EOF
systemctl daemon-reload
systemctl restart docker

Note: This removes the CPU pinning optimization, which may make docker pull ~2.7x slower due to TDX IPI overhead. See comments below for a dynamic cpuset switching approach that preserves fast pulls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions