我可以 pause/resume 一个 docker 容器吗?
Can I pause/resume a docker container?
我将 docker 桌面用于 windows(Linux 容器模式)到 运行 涉及高级波声学模拟和游戏开发预计算的批处理作业。在我的 AMD 3950x(16 核 32 线程)上,这项工作大约需要 11 天。问题是我也将计算用于其他工作(小型独立工作室在下班后使用计算机处理个人事务)。
所以我想暂停一下工作,这样我就可以用电脑做其他事情了。比稍后恢复它。这可能吗,我在 windows 的最新 Docker 桌面上。
有 docker pause
和 docker unpause
命令,值得一试。不过,我怀疑它无法在重启后继续存在。
您还可以启用一项实验性功能,该功能将持久保存到磁盘:https://docs.docker.com/engine/reference/commandline/checkpoint/。
有一个 pause and unpause 命令。但这些只是暂停进程,因此它们无法在机器重启后继续存在。
可能你想要一些持久的东西。为此,您可以在两个命令集之间进行选择:
save/load
使用 save command you will create a tar archive containing your current state of the container. With load 您可以重新开始该状态。缺点是图像的所有层都将被保存。因此,这可能会导致大量存档。
export/import
作为替代方案,您可以使用 export 导出容器的第一层。
The docker export command does not export the contents of volumes associated with the container. If a volume is mounted on top of an existing directory in the container, docker export will export the contents of the underlying directory, not the contents of the volume.
使用 import 可以再次创建容器。
好处是您最终得到的文件很小,而且导入速度更快,因为您的计算机上可能已经存在底层。
在这两种情况下,您都可以与其他机器共享生成的文件并将其存储在私有存储库中。
另请查看 migration guide 以获取更多灵感。
im on latest Docker desktop for windows.
11 月2021 年:使用最新的 Docker 桌面(包括 Windows),您不再需要 pause/unpause 每个容器一个接一个:
Docker Desktop 4.2 Release: Save Your Battery with Pause / Resume,
With Docker Desktop 4.2 we’re excited to introduce Pause / Resume as well as a host of changes to make it easier for you to manage updates.
These features are available to Docker Desktop users on any subscription tier.
Save your battery with Pause / Resume
Pause / Resume gives developers the power to pause their current Docker Desktop session and resume work whenever they want, saving resources on their machine while Docker is paused.
When you pause Docker Desktop, the current state of your containers is saved in memory and all processes are frozen. This lowers CPU usage and will help with saving your laptop’s battery life. To resume Docker Desktop, click either the Resume button in the menu or type any Docker CLI command in your terminal.
To try out this feature on Docker Desktop 4.2, navigate to the whale menu and click the ‘Pause’ button.
The corresponding content sections for Docker Desktop’s left sidebar items (e.g. Containers) will then be covered to clearly denote the Pause state.
Please note, Pause / Resume is currently not available in Windows container mod
我将 docker 桌面用于 windows(Linux 容器模式)到 运行 涉及高级波声学模拟和游戏开发预计算的批处理作业。在我的 AMD 3950x(16 核 32 线程)上,这项工作大约需要 11 天。问题是我也将计算用于其他工作(小型独立工作室在下班后使用计算机处理个人事务)。
所以我想暂停一下工作,这样我就可以用电脑做其他事情了。比稍后恢复它。这可能吗,我在 windows 的最新 Docker 桌面上。
有 docker pause
和 docker unpause
命令,值得一试。不过,我怀疑它无法在重启后继续存在。
您还可以启用一项实验性功能,该功能将持久保存到磁盘:https://docs.docker.com/engine/reference/commandline/checkpoint/。
有一个 pause and unpause 命令。但这些只是暂停进程,因此它们无法在机器重启后继续存在。
可能你想要一些持久的东西。为此,您可以在两个命令集之间进行选择:
save/load
使用 save command you will create a tar archive containing your current state of the container. With load 您可以重新开始该状态。缺点是图像的所有层都将被保存。因此,这可能会导致大量存档。
export/import
作为替代方案,您可以使用 export 导出容器的第一层。
The docker export command does not export the contents of volumes associated with the container. If a volume is mounted on top of an existing directory in the container, docker export will export the contents of the underlying directory, not the contents of the volume.
使用 import 可以再次创建容器。
好处是您最终得到的文件很小,而且导入速度更快,因为您的计算机上可能已经存在底层。
在这两种情况下,您都可以与其他机器共享生成的文件并将其存储在私有存储库中。 另请查看 migration guide 以获取更多灵感。
im on latest Docker desktop for windows.
11 月2021 年:使用最新的 Docker 桌面(包括 Windows),您不再需要 pause/unpause 每个容器一个接一个:
Docker Desktop 4.2 Release: Save Your Battery with Pause / Resume,
With Docker Desktop 4.2 we’re excited to introduce Pause / Resume as well as a host of changes to make it easier for you to manage updates.
These features are available to Docker Desktop users on any subscription tier.Save your battery with Pause / Resume
Pause / Resume gives developers the power to pause their current Docker Desktop session and resume work whenever they want, saving resources on their machine while Docker is paused.
When you pause Docker Desktop, the current state of your containers is saved in memory and all processes are frozen. This lowers CPU usage and will help with saving your laptop’s battery life. To resume Docker Desktop, click either the Resume button in the menu or type any Docker CLI command in your terminal.
To try out this feature on Docker Desktop 4.2, navigate to the whale menu and click the ‘Pause’ button.
The corresponding content sections for Docker Desktop’s left sidebar items (e.g. Containers) will then be covered to clearly denote the Pause state.Please note, Pause / Resume is currently not available in Windows container mod