dockerfile 内容如下
# alpine 无法安装 scipy 和 numpy
FROM python:3.9
MAINTAINER Mrli [email protected]
ADD log_utils/ /app
ADD docker-entrypoint.sh /app
WORKDIR /app
RUN mkdir logs/
ADD ext/ /app/logs
VOLUME /app/logs
EXPOSE 8097
# alpine 中 pip 安装 Scipy 等科学相关的包时报错, 需要预先安装的库
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk --update-cache --no-cache add tzdata gcc make freetype-dev gfortran musl-dev g++ libgcc libquadmath musl libgfortran lapack-dev
#RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple \
# && chmod 777 ./repeat.sh \
# && chmod 777 ./docker-entrypoint.sh \
&& bash ./repeat.sh
ENTRYPOINT python -m visdom.server
#ENTRYPOINT ["bash", "./docker-entrypoint.sh"]
repeat.sh 内容如下
#!/bin/bash
echo "Start Record"
ENV_DIR=$(cd $(dirname $0);pwd)
# source $ENV_DIR/env/bin/activate
# pyenv activate py38
nohup python -u checkRepeatSituation.py 1> r1.log 2>err.log &
nohup python -u checkRepeatSituation1.py 1> r2.log 2>err.log &
nohup python -u checkRepeatSituation3.py 1> r3.log 2>err.log &
nohup python -u checkRepeatSituation4.py 1> r4.log 2>err.log &
#nohup python -m visdom.server &
运行命令如下docker build -t nymrli/cplm_record:v2 .
, docker run -d -p 23333:8097 -v /var/log/cplm:/app/logs --name cplm nymrli/cplm_record:v2
想请问一下为什么容器中 nohup 的内容没有执行
1
mimzy 2021-10-25 00:08:21 +08:00
nohup 命令在构建镜像的时候执行完了。你起容器只会执行 ENTRYPOINT 的命令,可以把 nohup 的命令和你的 python -m visdom.server 写到启动脚本里,ENTRYPOINT 设置为启动这个脚本。
|