我在docker中有一些脚本,我应该
我正在尝试使用docker来自动部署。
FROM phusion/baseimage:0.9.15
MAINTAINER neetu
ENV HOME /root
RUN mkdir /buzzbuild
RUN apt-get update && apt-get install -y -q dos2unix
ADD ./ /buzzbuild
RUN cd /buzzbuild/dockscripts/ && chmod 755 install.sh && sh install.sh
ADD dockscripts/service/. /etc/service/
RUN chown root /etc/service/ && chmod 777 -R /etc/service/
WORKDIR /buzzbuild
CMD ["/sbin/my_init"]
EXPOSE 80 443 5000 15672
#!/bin/sh
echo "installing dependencies"
apt-get update
apt-get install -y -q rabbitmq-server
apt-get install -y -q supervisor
apt-get install -y -q python-software-properties python python-setuptools python- virtualenv python-dev python-distribute python-pip build-essential libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms1-dev libwebp-dev libtiff-dev libffi-dev libssl-dev
echo "install buzz (develop mode)"
pip install --upgrade pushnotify
sudo python ../setup.py install
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins enable rabbitmqadmin
rabbitmq-server -detached && sleep 5 && rabbitmqctl start_app && python ../buzz/scripts/setuprabbit.py && rabbitmqctl stop_app
echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config
echo "NODENAME=rabbit@localhost" > /etc/rabbitmq/rabbitmq-env.conf
现在问题是......当运行myscript时,似乎它无法识别安装程序已经发生,因此抱怨导入我创建的模块。如果我在docker shell中执行python setup.py install
,则相同的脚本可以正常工作!
任何指针?
答案 0 :(得分:0)
安装python后检查是否有两个版本的python 在我的Dockerfile中的preinstall.sh中,我将这样做:(ops-python是本地包rpm,基本操作系统映像是centos)
####part of script
yum clean all
yum install ops-python -y
ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
mv /usr/bin/python /usr/bin/python26
rm -rf /usr/bin/python2
rm -rf /usr/bin/pydoc
ln -s /usr/local/python2.7/bin/* /usr/bin/
sed -i 's/python/python26/' /usr/bin/yum
python ez_setup.py
####part of scripts
我想在你apt-get
安装python之后,新版python没有转向默认
例如:
你有apt-get
安装python和python-pip all for version 2.7
和python2.7的pip install
模块
但你的默认python是python2.6
那你sudo python ../setup.py install
可能是使用python2.6,所以它找不到python2.7安装的python模块
我想是的,您可以附加到您的容器并检查您的python版本和根env。
希望这些能给你一些帮助。