1024程序猿/程序媛节日快乐,更新个文章庆祝一下节日
最近机器学习的docker总是因为显存不足导致崩溃,崩溃之后就无法提供服务,验看了下,最终发现在启动命令中没有加入–restart=always的命令
原命令:
‘nvidia-docker run {it} -p {port}:{in_port} -v {model_dir}/:/luyouli vision:{image} /luyouli/{date}/config.yaml {v}’
新命令:
‘nvidia-docker run {it} –restart=always -p {port}:{in_port} -v {model_dir}/:/luyouli vision:{image} /luyouli/{date}/config.yaml {v}’
但是已经启用的docker就不能通过新建的方法解决了,需要更新配置
# docker update –restart=always Container_ID
# docker inspect Container_ID
找到RestartPolicy
"RestartPolicy": { "Name": "always", "MaximumRetryCount": 0 }

这样就解决了重启docker-ce之后的容器启动问题
随之而来的是另一个问题,我要删除一个配置了restart=always的容器的话,需要先删除restart的配置,否则这个容器会一次一次又一次的自动启动启动再启动
# docker update –restart=no Container_ID
找到刚才配置

这样,就解决了容器无法删除的问题
官网地址:
https://docs.docker.com/engine/reference/run/
Restart policies (–restart)
Using the --restart
flag on Docker run you can specify a restart policy for how a container should or should not be restarted on exit.
When a restart policy is active on a container, it will be shown as either Up
or Restarting
in docker ps
. It can also be useful to use docker events
to see the restart policy in effect.
Docker supports the following restart policies:
Policy | Result |
---|---|
no | Do not automatically restart the container when it exits. This is the default. |
on-failure[:max-retries] | Restart only if the container exits with a non-zero exit status. Optionally, limit the number of restart retries the Docker daemon attempts. |
always | Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container. |
unless-stopped | Always restart the container regardless of the exit status, including on daemon startup, except if the container was put into a stopped state before the Docker daemon was stopped. |
Excellent post. I will be dealing with a few of these issues as well..
Attractive section of content. I just stumbled upon your blog and in accession capital to assert that I get actually enjoyed account your blog posts.
Anyway I will be subscribing to your feeds and even I achievement you
access consistently fast.
I’d like to thank you for the efforts you’ve put in penning this site.
I really hope to view the same high-grade blog posts by you
in the future as well. In fact, your creative writing
abilities has inspired me to get my very own website now 😉
This is really interesting, You’re a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your fantastic post.
Also, I’ve shared your website in my social networks!
Very good blog! Do you have any hints for aspiring writers?
I’m planning to start my own blog soon but I’m a little
lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so
many options out there that I’m totally confused .. Any suggestions?
Appreciate it!
excellent publish, very informative. I’m wondering why the opposite specialists of this sector do not understand this.
You must proceed your writing. I’m confident, you’ve a huge
readers’ base already!