fix: 容器内以 root 运行以访问 Docker socket,docker compose 改为 docker-compose
This commit is contained in:
+4
-2
@@ -54,8 +54,10 @@ RUN chown -R nextjs:nodejs /app
|
||||
# 安装 git(版本检查、拉取更新)和 docker CLI(构建/重启容器)
|
||||
USER root
|
||||
RUN apk add --no-cache git docker-cli docker-compose
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
USER nextjs
|
||||
# 以 root 运行以确保有权限访问挂载的 Docker socket /var/run/docker.sock
|
||||
# 若需以非 root 运行,需在宿主机上执行:
|
||||
# sudo chmod 666 /var/run/docker.sock
|
||||
# 或在容器入口脚本中动态匹配 socket 的 group GID
|
||||
|
||||
EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
|
||||
+2
-2
@@ -297,7 +297,7 @@ export async function executeUpdate(
|
||||
|
||||
// 3. 构建新镜像
|
||||
onLog("[3/4] 构建新 Docker 镜像");
|
||||
execSync(`cd "${tmpDir}" && docker compose -p recipe_tool build`, {
|
||||
execSync(`cd "${tmpDir}" && docker-compose -p recipe_tool build`, {
|
||||
encoding: "utf-8",
|
||||
timeout: 600000,
|
||||
windowsHide: true,
|
||||
@@ -307,7 +307,7 @@ export async function executeUpdate(
|
||||
|
||||
// 4. 重启服务
|
||||
onLog("[4/4] 重启服务");
|
||||
execSync(`cd "${tmpDir}" && docker compose -p recipe_tool up -d`, {
|
||||
execSync(`cd "${tmpDir}" && docker-compose -p recipe_tool up -d`, {
|
||||
encoding: "utf-8",
|
||||
timeout: 60000,
|
||||
windowsHide: true,
|
||||
|
||||
Reference in New Issue
Block a user