Skip to content

Commit

Permalink
Add section of backup and restore instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jan 11, 2024
1 parent fbde59c commit 8dbbb7e
Showing 1 changed file with 64 additions and 17 deletions.
81 changes: 64 additions & 17 deletions docs/source/intro/run_docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ This image contains a fully pre-configured AiiDA environment which makes it part

Docker Desktop is available for Windows and Mac and includes everything you need to run Docker on your computer.
It is a virtual machine + Graphical user interface with some extra features like the new extensions.

`Docker Desktop <https://www.docker.com/products/docker-desktop/>`_ is the easiest way to get started with Docker.
You just need to download the installer and follow the instructions.

.. tab-item:: Colima on MacOS and Linux

`Colima <https://github.com/abiosoft/colima>`_ is a new open-source project that makes it easy to run Docker on MacOS and Linux.
It is a lightweight alternative to Docker Desktop with a focus on simplicity and performance.

If you need multiple Docker environments, Colima is the recommended way.
With colima, you can have multiple Docker environments running at the same time, each with its own Docker daemon and resource allocation thus avoiding conflicts.

Expand Down Expand Up @@ -119,7 +121,7 @@ Congratulations! You have a working AiiDA environment, you can start using it.

If you use the Docker image for the development or for the production environment, you are likely to need some extra settings to make it work as you expect.

.. drowpdown:: Copy files from your computer to the container
.. dropdown:: Copy files from your computer to the container

.. tab-set::

Expand Down Expand Up @@ -150,42 +152,87 @@ If you use the Docker image for the development or for the production environmen
.. dropdown:: Persist data across different containers

The lifetime of the data stored in a container is limited to the lifetime of that particular container.

If you stop the container (`docker stop` or simply `Ctrl+D` from the container) and start it again, any data you created will persist.
However, if you remove the container, **all data will be removed as well**.

.. code-block:: console
$ docker rm aiida-container
The preferred way to persistently store data is to `create a volume <https://docs.docker.com/storage/volumes/>`__.

.. tab-set::

.. tab-item:: Docker Desktop

1. Open Docker Desktop
1. ???

.. tab-item:: Docker CLI

To create a simple volume, run:

.. code-block:: console
$ docker volume create container-home-data
Then make sure to mount that volume when the first time launching the aiida container:

.. parsed-literal::
$ docker run -it --name aiida-container -v container-home-data:/home/aiida aiidateam/aiida-core:latest bash
Starting the container with the above command, ensures that any data stored in the ``/home/aiida`` path within the container is stored in the ``conatiner-home-data`` volume and therefore persists even if the container is removed.

To persistently store the Python packages installed in the container, use `--user` flag when installing packages with pip, the packages will be installed in the ``/home/aiida/.local`` path which is mounted to the ``container-home-data`` volume.

You can also mount a local directory instead of a volume and to other container paths, please refer to the `Docker documentation <https://docs.docker.com/storage/bind-mounts/>`__ for more information.

.. dropdown:: Backup the container

To backup the data of AiiDA, you can still follow the instructions in the `Backup and restore <backup_and_restore>`__ section.
However, the container provide a more convinient way if you just want to take a snapshot of the data by backup the whole container or the volume mounted to the container.

This part is adapt from the `Docker documentation <https://docs.docker.com/desktop/backup-and-restore/>`__.

If you don't have a volume mounted to the container, you can backup the whole container by commit the container to an image:

.. parsed-literal::
$ docker container commit aiida-container aiida-container-backup
The above command will create a new image named ``aiida-container-backup`` which contains all the data and modifications you made in the container.

Use `docker push` to push the ``aiida-container-backup`` image to a registry if you want to share it with others.

Alternatively, you can also export the container to a local tarball:

.. parsed-literal::
$ docker save -o aiida-container-backup.tar aiida-container-backup
To restore the container, pull the image or load from the tarball, run:

.. parsed-literal::
$ docker load -i aiida-container-backup.tar
If you used a `named volume <https://docs.docker.com/storage/volumes/#backup-a-containerhttps://docs.docker.com/storage/#more-details-about-mount-types>`__, you can backup the volume.

.. tab-set::

.. tab-item:: Docker Desktop

Docker Desktop provides a `Volumes Backup & Share extension <https://hub.docker.com/extensions/docker/volumes-backup-extension>`__ which allows you to backup and restore volumes effortlessly.

The extension can be found from the Marketplace in the Docker Desktop GUI.
Install the extension and follow the instructions to backup and restore volumes.

.. tab-item:: Docker CLI

Please check `Backup, restore, or migrate data volumes <https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes>`__ for more information.

.. button-ref:: intro:get_started:next
:ref-type: ref
:expand:
Expand Down

0 comments on commit 8dbbb7e

Please sign in to comment.