docker - 如何在 Docker 容器中升级 Strapi?
问题描述
我用 Docker-compose启动了Strapi 。看了迁移指南,还是不知道要不要升级到下一个版本,应该选择什么方法:
- 在 Strapi 项目目录下,执行
npm install strapi@<next version> -g
并npm install strapi@<next version> --save
docker exec -it <strapi container> sh
,导航到 Strapi 项目目录,然后npm install strapi@<next version> -g
执行npm install strapi@<next version> --save
- 两者都不?
解决方案
In your local developer tree, update the package version in your
package.json
file. Runnpm install
oryarn install
locally. Start your application. Verify that it works. Run your tests. Fix any compatibility issues from the upgrade. Do all of this without Docker involved at all.Re-run
docker build .
to rebuild your Docker image with the new package dependencies.Stop the old container, delete it, and run a new container with the new image.
As a general rule you should never install anything in a running container. It's extremely routine to delete containers, and when you do, anything in the container will be lost.
There's a common "pattern" of running Node in Docker, bind-mounting your application into it, and then mounting an anonymous volume over your node_modules
directory. For routine development I've found it vastly simpler to just install Node on my host (it is literally a single apt-get install
or brew install
command). If you're using this Docker-oriented setup, the anonymous volume for node_modules
won't notice that you've changed your node_modules
directory, and you have to re-run docker build
and delete and recreate your containers.
推荐阅读
- node.js - 如何使用 Puppeteer 读取 span 元素的值
- servicestack - 如何在 ServiceStack 5.0 项目中使用来自 ServiceStack 4.0 的服务模型?
- mysql - 节点服务器 - 使用 mysql 连接的正确方法
- c++ - 这个算法的运行时间复杂度是多少?您如何对其进行分析?
- debian - 使 git-buildpackage 与大 tarball 一起工作
- batch-file - 批量将文件移动到以相同编号开头的文件夹
- azure - 如何在 Microsoft Azure 的应用服务中安装 .exe?
- python - 无法以 root 身份运行 PyCharm 解释器
- bash - 查找目录但排除目录名称中有空格的列表
- c# - 如何在 WPF 中捕获 DataTemplate 的实例化?