I read some articles about using a virtual environment in Docker. Their argument are that the purpose of virtualization in Docker is to introduce isolation and limit conflicts with system packages etc.

However, aren’t Docker and Python-based images (e.g., python:*) already doing the same thing?

Can someone eli5 this whole thing?

  • uthredii@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    4 months ago

    upgrading your base image won’t affect your python packages

    Surely if upgrading python will affect your global python packages it will also affect your venv python packages?

    you can use multi stage builds to create drastically smaller final images

    This can also be done without using venv’s, you just need to copy them to the location where global packages are installed.

    • sweng@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      4 months ago

      Upgrading the base image does not imply updating your python, and even updating your python does not imply updating your python packages (except for the standard libraries, of course).

      • uthredii@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        4 months ago

        Sure, but in the case where you upgrade python and it affects python packages it would affect global packages and a venv in the same way.

        • sweng@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          4 months ago

          Sure If that happens. But it may also not. Which is actually usually the case. Sure, it’s not 100% safe, but it is safer.