更改 Docker 存储后端

Hello all,

I have been using Docker with the Devicemapper storage driver. After manually editing the launcher script, I finally took the time to convert to Overlay2. Here are the instructions I took to do this. I hope this helps others. I see others have asked the question, but I don’t see any answers. I used this excellent guide to help figure this out.

Step 1: Halt your Discourse application (and other docker apps)

./launcher stop app

Step 2: Commit and save your old Docker containers/images

We first committed each image we care for so that we had the most recent version tagged somewhere with all changes included. This can be done roughly like this:

docker ps -a
# for each container you care for, stop and then commit it
docker commit e198aac7112d export/local_discourse_app 
docker save export/local_discourse_app > export_local_discourse_app.tar.gz

Step 3: Change storage driver

I chose Overlay2, but the Discourse-recommended driver is aufs. Adjust as necessary. If something goes wrong, simply set the storage-driver to devicemapper as needed.

Insert the following into /etc/docker/daemon.json

{
  "storage-driver": "overlay2"
}

Step 4: Restart docker

sudo service docker restart

Step 5: Import image into new storage device

docker load < export_local_discourse_app.tar.gz

Step 6: Rebuild Discourse

./launcher rebuild app

I hope this helps! Feel free to suggest any modifications or questions.

18 个赞

你好!抱歉打扰了,但我使用 Discourse 已有两年,现在正尝试了解其插件开发流程。
我有一台刚安装 Ubuntu 16.04 的 VPS,Docker 默认使用 devicemapper 存储驱动。我无法更改此设置(该教程以及网上的其他资料都导致 Docker 无法启动)。有什么建议吗?

为什么选择已经相当过时的 Ubuntu 16.04?为什么不使用 18.04?

我试过这两个,我觉得我的 VPS 不支持那个内核或其他什么东西。我在同一家公司有一个更好的 VPS,没有任何问题…

我猜这之后你可以(应该?)删除 /var/lib/docker/aufs 目录和 export_local_discourse_app 文件?