我正在使用Docker在启动容器时执行一个命令,但是似乎环境变量没有从.bashrc文件中获得,请给我一些建议。
谢谢
Dockerfile我将此添加到.bashrc:
echo "export PYTHONPATH=$PYTHONPATH:/models/research:/models/research/slim" >> /root/.bashrc
docker-compose.yml文件具有:
command: ["python2", "/usr/bin/supervisord", "--nodaemon", "--configuration", "/etc/supervisor/supervisord.conf"]
注意:如果我从container执行echo$pythpath或只是执行python2/usr/bin/supervisord-c/etc/supervisor/supervisor.conf,则没有问题。
系统是ubuntu 16.04
主管配置:
[program:mosquitto-subscrible]
process_name=%(program_name)s_%(process_num)02d
command=python3 detection.py start_mosquitto_subscrible
autostart=true
autorestart=true
user=root
numprocs=1
directory=/var/www/html/detection
redirect_stderr=true
stdout_logfile=/var/www/html/detection/logs/detection.log
docker-compose.yml文件
version: '3'
services:
tensorflow:
container_name: object-detection
build:
context: ./tensorflow
dockerfile: Dockerfile
# environment:
# - PYTHONPATH=:/models/research:/models/research/slim
volumes:
- ./www:/var/www/html:cached
- ./tensorflow/supervisor:/etc/supervisor/conf.d
command: ['tail', '-f', '/dev/null']
# command: ["python2", "-c", "/usr/bin/supervisord", "--nodaemon","--configuration", "/etc/supervisor/supervisord.conf"]
最后,我用温顺的语言写了一个命令
echo“export pythonpath=$pythonpath:/models/research:/models/research/slim”>>/root/.bashrc
制作/模型/研究可以通过python找到。
有一个python模型
/models/research/object_detection
.
我的上司,指挥部
python3 detection.py start_mosquitto_subscrible
如果我启动,找不到对象探测模型
supervisord
只是从Docker编写命令,而不是在Docker容器中执行它。
主管需要python2启动,我的代码需要python3