Two containers – two Pythons – one site-packages?

Let’s assume I have two separate docker (or some other) containers which may only share folders with each other. There is a Python interpreter of the same version installed in both of these containers. Is there any way to make these interpreters to share almost the same PYTHONPATH, e.g. for both of them see all packages installed in any of these containers?

I know I can just import packages from a folder, but I want do find out if it’s possible to do such steps:

  • Docker Registry incorrectly claims an expired CA cert
  • kubernetes replication controller
  • Get the size of a Docker image before a pull?
  • How to change ip address to domain name in ionic application
  • Add Logtrail plugin to kibana to see the logs in kibana ui - openshift/origin-aggregated-logging
  • Will single docker container scale automatically on Amazon's EC2?
    1. Install package A in first container with pip or easy_install. This package may depend on other packages, which are located in second container and somehow mounted to first one. Also, there are some possible dependencies (which second container is missing) which will be installed into first container.
    2. Inside second container import package A from first container without issues, so it should see both dependencies located in first and second containers.

    The thing is, I’m trying to use stevedore to look for packages by entry points, but they should be installed and, possibly, upgraded independently from what’s installed in second container.

  • Can't reach Asp.Net Core inside Docker
  • Connect Rails/Unicorn/Nginx container to MySQL container
  • How to control how many docker services to run on each EC2?
  • Moving Phundament web app to production
  • CHEF provisioning: SystemStackError: stack level too deep
  • Nginx proxy pass real ip doesn't work
  • 2 Solutions collect form web for “Two containers – two Pythons – one site-packages?”

    I do not know if I understood the question. If this does not answer your question, could you comment? To me there were like three questions you asked:

    1. import behavior (I answered below)
    2. Updating packages
    3. stevedore – optional or not, a try or a requirement?

    Import Behavior

    There is a list called sys.path. It is the list of folders in which python looks for packages.
    Suppose you have folder1 and folder2 in this list.

      +----- module_a
      +----- module_b
      +----- module_a
      +----- module_c

    A Python process with ['folder1', 'folder2', ...] as sys.path would do that:

    import module_a # from folder1
    import module_b # from folder1
    import module_c # from folder2

    A Python process with ['folder2', 'folder1', ...] as sys.path would do that:

    import module_a # from folder2 # difference
    import module_b # from folder1
    import module_c # from folder2

    This is how I understand the Python import behavior. I do not use docker or PYTHONPATH, so I can not refer to that.

    You could have a container whose entry point creates a virtualenv in a volume and installs all the dependencies defined in a requirements file. Then you could use the –volumes-from flag to mount the virtual env in other containers and execute the activate script to import the environment..

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