Loosing modifications after rerunning container

My problem is that when I run a container, modify a file, exit and rerun the container, I see that changes have been lost. Here are the steps that I took.

1- Run nvidia-docker run -v pwd/..:/data --rm -it mlperf-nvidia:minigo
2- Update pip and exit

root@d5137ad8809c:/opt/reinforcement# python3 -m pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.8/dist-packages (21.2.4)
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 11.0 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.4
    Uninstalling pip-21.2.4:
      Successfully uninstalled pip-21.2.4
Successfully installed pip-22.0.4
root@d5137ad8809c:/opt/reinforcement# pip3 list | grep pandas
pandas                        1.4.2
root@d5137ad8809c:/opt/reinforcement# exit

3- Rerun the command and see the pip3 is still in the old version.

root@e7f6151e12bb:/opt/reinforcement# pip3 list | grep pandas
pandas                        1.4.2
WARNING: You are using pip version 21.2.4; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python -m pip install --upgrade pip' command.

Any thoughts on that?

You should indeed not rely on storing data or keeping other changes in containers (even less so when using --rm to delete the container after shutting it down).

I very much recommend going through the interactive “Get started” which explains this in Part 5: Persist the DB. (But I’d start from part 1 in that guide.)

1 Like

Oh, and as for pip and all to create a Python environment, rather than updating that in the container, you may want to update pip in the image you’re using to create that container. So, probably some RUN command in a Dockerfile.

And as for documentation: there is also a Python specific guide, but I’ve no idea if that applies to whatever you’re trying to use pip for in your Nvidia image.