Docker Community Forums

Share and learn in the Docker community.

How to use --gpus option with docker-compose?

Hello everyone.

I try to use --gpus option that is new feature version 19.03.
I check that has work with docker run command, but I couldn’t find how to write that in docker-compose file.

Would anyone tell me how to use that?
Or the feature is not available yet?

Kind Regards,

1 Like

Even though Docker 19.03 was released, I am afraid you will have to wait for docker-compose to catch up and implement the new features as well.For time beeing the latest docker-compose release was 1.24.1 from June, 24th this year.

The docker compose file referens are still v2.4 for docker-compose and v3.7 for Docker Swarm deplyoments.

There is always an option to “cheat”. Declare a service inside your docker-compose.yml based on a docker on docker image and put your docker run statement in the command section. Though, I would strongly advice to wait for the update of docker-compose and updated file versions.

@meyay

Thanks for your reply.
Your explanation really helped.
I understood relation of docker and docker-compose versions.
And I found docker-compose file compatibility matrix.

OK, I will wait for docker-compose to catch up.
(without experiment “docker in docker” cheat.)
Thank you.

2 Likes