0

I would like to restart a docker container, after exiting it and rebooting, with the same runtime with which it was initially created.

Here's what I did so far.

Create the container:

sudo docker run --runtime=nvidia [...]

Restart Docker after exiting the container and rebooting:

service docker restart

Restart the container previously created:

sudo docker start my_container

Reopen the container.

docker exec -it my_container [...]

The program which is then launched in the container doesn't use the Nvidia GPU as expected. It instead uses the system CPU.

Any help would be greatly appreciated.

plugz
  • 1
  • 3
  • What do you mean by same runtime? DO you mean you need your docker container to be running on system reboot/startup or even on docker service restart? – mchawre Aug 24 '19 at 14:07
  • I'd like the nvidia GPU to be used when commands are run in the restarted container. – plugz Aug 24 '19 at 17:41
  • You mean the `--runtime=nvidia` option of docker run should always work and point to nvidia runtime? – mchawre Aug 24 '19 at 17:43
  • Not always, only for the specific container that was created using the `--runtime=nvidia` option. There's probably a concept I'm missing about Docker, but when I first create the container (with the `run` command) the program I launch within it executes using the nvidia GPU, which is not the case when I exit the container then reopen it with the `exec` command. – plugz Aug 24 '19 at 21:01
  • It happens that the problem occurs only on system reboot. If I simply `stop` the container then `start` it again, the nvidia GPU is sill used. I would guess the runtime is unregistered on reboot. – plugz Sep 04 '19 at 18:40
  • in your docker run command make use of `--restart=always` option. Give it a try and let me know, if it works on reboot with correct runtime. – mchawre Sep 05 '19 at 04:52

1 Answers1

0

I got the expected result by creating a new container with the --restart=unless-stopped policy, which lets Docker restart the container by itself when the Docker service is restarted. There seems to be more that's being done in this process than the start/exec sequence that I was using.

plugz
  • 1
  • 3