Unable to preserve setup.py install state in docker container

I have a few scripts in docker for which I should

  1. install and run rabbitmq-server
  2. run a python script to setup exchanges and queues setuprabbit.py
  3. python setup.py install
  4. and run a few scripts of my own myscript.py myscript2.py myscript3.py

I am trying to use docker now to automate the deployment.

  • Changes to css, js, and static files not reflected on nginx docker container
  • Bad gateway error on target website configured using the “nginx-proxy” docker container
  • Access webcam using OpenCV (Python) in Docker?
  • Create your own Docker (sub-)commands
  • How to test external services from inside a Docker container?
  • Docker container with multiple network interfaces: get only one IP address
  • My dockerfile

    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

    my install.sh (does most of the above work)

    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

    Now the problem is… when myscripts are run, it seems like it does not recognize that setup install has already happened and hence complains about importing the modules I created. If I do a python setup.py install in the docker shell the same script works!

    any pointers?

  • Execute script inside docker container which is folder different than WORKDIR
  • How to open a shell while/after running a Docker container without overriding existing CMD?
  • Java webapp to Tomcat 8 running in Docker container at localhost
  • Docker 1.6 and Registy 2.0
  • Docker client certificate issue
  • OS name for docker images
  • One Solution collect form web for “Unable to preserve setup.py install state in docker container”

    Check out after you install python is there two version python.
    In my preinstall.sh in Dockerfile i will do like this:(ops-python is over local package rpm, and base OS image is 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

    I guess after you apt-get install python, the new version python not turn to default.
    For exmple:
    you have apt-get install python and python-pip all for version 2.7
    and pip install modules for python2.7
    but your default python is python2.6
    then you sudo python ../setup.py install maybe is use the python2.6, so it cannot find installed python modules for python2.7

    I guess so, you can attach to your container and check your python version and your root env.

    Hope these give you some help.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.