Docker: Persisting User Data
I’m busy putting together a Docker image for a multi-user Jupyter Notebook installation. I am to have an independent login for each of the users and each of them should also have their own storage space. That space should exist elsewhere from on the container though, so that even if the container stops, the data lives on. This should mitigate user rage.
There are number of options for achieving this but I’m simply going to persist the data onto the Docker host.
Adding a Volume
On the host machine you could create a new folder to hold the user content. However, it makes sense to just use
/home/. Start your docker container with the
-v option which binds a location on the host to a location on the container.
Now make a shell connection to the container.
We’ll be using the
mkpasswd command to generate encrypted passwords, so we need to install the
Now you can create users.
It’s critical that the argument to the
-p flag is generated by
mkpasswd, otherwise logging in as this user won’t work!
That will create a
jupyter folder under
/home/ on the container.
It will also add an entry to
If we now exit the shell connection and check the
/home/ folder on the host we’ll find that it is where the home folder for the
jupyter user is located.
Finish and klaar.