方案一:使用 nohup 忽略挂断信号
nohup docker-compose up -d > build.log 2>&1 &
- 构建过程会在后台运行,输出重定向到
build.log - 关闭终端不影响进程
- 可以用
tail -f build.log实时查看进度
方案二:使用 screen(推荐)
# 创建一个名为 plane 的会话 screen -S plane # 在 screen 中执行构建 docker-compose up -d # 按 Ctrl+A 然后按 D 分离会话 # 关闭终端,重新连接后恢复会话 screen -r plane
方案三:使用 tmux
# 创建会话
tmux new -s plane
# 执行构建
docker-compose up -d
# 分离会话:Ctrl+B 然后按 D
# 重新连接
tmux attach -t plane


发表回复