# Developing inside aiidalab docker environment

**URL:** <https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185>\
**Category:** General Usage\
**Created:** [December 1, 2023, 10:21am UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185 "2023-12-01T10:21:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xing](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/xing/32/10_2.png) [@Xing](https://aiida.discourse.group/u/Xing)\
**Post date:** [December 1, 2023, 10:21am UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/1 "2023-12-01T10:21:29Z")

</div>

When starting a new developing environment for AiiDA/AiiDAlab. There are many choices, e.g., conda, docker, VM. In this post, I’d like to share my firsthand experience using the AiiDAlab Docker image in the hope that my insights can benefit others.

**Creating a New Profile**  
To begin, we’ll create a new profile named ‘dev-aiidalab’ using the ‘aiidalab-launch’ :

```console
aiidalab-launch profile add --image aiidalab/qe:edge dev-aiidalab

```

**Installing Packages as Root Inside the Docker Container**

```console
docker exec -it -u root xxx_container_id /bin/bash

```

Inside the container, you can update the package list and install any necessary packages. For instance, if you require ‘plocate’ for ‘pgtest,’ you can run:

```console
sudo apt update
# used for pgtest
sudo apt install plocate

```

More insights and tips will be added shortly.

### RabbitMQ

If you want to use the `verdi devel rabbitmq` command to interact with RabbitMQ.

```console
# rabbitmq is installed in a separate conda environment.
conda activate aiida-core-services
rabbitmq-plugins enable rabbitmq_management
conda deactivate

```

### Github gh command

```console
conda install -c conda-forge gh

```

Login your github account

```console
gh auth login

```

### Backup

In some cases, the container can not start anymore due to unknown reasons. Don’t worry that your data is still there. Typically, it is In the folder

```auto
/var/lib/docker/volumes/aiidalab_dev-aiida_home/_data/

```

You can backup this data, reset the profile

```console
aiidalab-launch reset -p dev-aiida

```

and create a new profile again.

**Share Your AiiDAlab Docker Experience**

If you have any experiences or insights to share regarding the AiiDAlab Docker environment, please feel free to contribute by adding a comment below. Your input can be invaluable to the community.

---

<div class="post-metadata">

**Author:** ![giovannipizzi](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/giovannipizzi/32/17_2.png) [@giovannipizzi](https://aiida.discourse.group/u/giovannipizzi)\
**Post date:** [December 1, 2023, 4:30pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/2 "2023-12-01T16:30:32Z")

</div>

Thanks! Once we collect some feedback, this would be good for a blog post?

---

<div class="post-metadata">

**Author:** ![jusong.yu](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/jusong.yu/32/3_2.png) [@jusong.yu](https://aiida.discourse.group/u/jusong.yu)\
**Post date:** [December 13, 2023, 3:56pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/3 "2023-12-13T15:56:30Z")

</div>

Thanks @Xing, it is super nice you started using it and provided your experience on how to use the images.

Per @giovannipizzi suggestion, I was planning to convert [Building Docker Image with Pre-configured AiiDA Computer? - #3 by jusong.yu](https://aiida.discourse.group/t/building-docker-image-with-pre-configured-aiida-computer/132/3) to a blog. But I think you are right, using and developing inside the container deserves a dedicated blog as well.  
Although we have some users who started using it, but we have not yet advertised it. Still, some minor things need to be settled such as how to backup the data.

@Xing’s post is using AiiDAlab image, now there are `aiida-core-with-services` images for `aiida-core` specifically. It includes some developer’s optimization configure such as preinstalled `plocate` (it is in the aiidalab image as well but not in the `base` conda environment, another way to get `pgtest` for pytest in the AiiDAlab container is to run `conda activate aiida-core-services`).

Just use this post to list things need to do to make the images more accessible and useful.

- Polish the documentation: [Run AiiDA via a Docker image — AiiDA 2.4.0.post0 documentation](https://aiida.readthedocs.io/projects/aiida-core/en/latest/intro/run_docker.html#intro-get-started-docker) and adding section on the recommended way to backup the data or entire container.
- A tutorial-like blog includes videos on how to easily get docker running from docker desktop and user stories as @Xing’s post.
- From my side, I want to also push to developing inside container with using vscode, which brings a lot of convenience like no need to further set up GitHub credentials.

---

<div class="post-metadata">

**Author:** ![jusong.yu](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/jusong.yu/32/3_2.png) [@jusong.yu](https://aiida.discourse.group/u/jusong.yu)\
**Post date:** [December 13, 2023, 4:13pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/4 "2023-12-13T16:13:49Z")

</div>

The add on the topic, I use `aiida-core-with-services` image as the burn-after-reading solution to play with AiiDA archives downloaded from MaterialsCloud.

First I download `acwf-verification_unaries-verification-PBE-v1_results_abinit_PseudoDojo_0.5b1_PBE_SR_standard_psp8.aiida` archive from [Materials Cloud Archive](https://archive.materialscloud.org/record/2023.81)

Then I open a container from image `aiida-core-with-services:latest` with `--rm` option to destroy the container after exiting from the shell.

```shell
docker run --rm -it --name test-container aiidateam/aiida-core-with-services:latest bash

```

Open a new shell and copy the archive into the container by:

```shell
docker cp acwf-verification_unaries-verification-PBE-v1_results_abinit_PseudoDojo_0.5b1_PBE_SR_standard_psp8.aiida test-container:/home/aiida

```

Inside the container shell, import the archive by:

```shell
verdi archive import acwf-verification_unaries-verification-PBE-v1_results_abinit_PseudoDojo_0.5b1_PBE_SR_standard_psp8.aiida

```

Then it is ready to run `verdi shell` and play with the queries. The advantage of this is the tedious profile-creating process is avoided. Also, the container will be destroyed once exit from the container shell. To keep the container so it is can be reached next time, just not using the `--rm` option. To restart the container, simply run `docker start -i test-container`, and the shell will come back.

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [December 13, 2023, 4:32pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/5 "2023-12-13T16:32:10Z")

</div>

Good stuff @jusong.yu . As an alternative, for people that don’t have Docker or are not used to it, once [this PR is merged](https://github.com/aiidateam/aiida-core/pull/6224) and released with v2.5, users will be able to do the following:

```auto
verdi profile setup core.sqlite_zip -n --profile temp-profile --filepath path/to/archive.aiida

```

This will create a profile based on the archive. They can then `verdi shell` to inspect the content or run any Python script that loads the profile. Once they are done, they run

```auto
verdi profile delete temp-profile

```

to delete the profile.

---

<div class="post-metadata">

**Author:** ![giovannipizzi](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/giovannipizzi/32/17_2.png) [@giovannipizzi](https://aiida.discourse.group/u/giovannipizzi)\
**Post date:** [December 13, 2023, 8:15pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/6 "2023-12-13T20:15:47Z")

</div>

Great suggestions and comments! I also would be interested in easy development with VS code and a container.

@sphuber one question - when you do verdi profile delete, will it also delete the .aiida file? To be consistent with the usual delete behaviour, I think it should, on the other hand it might be unexpected? (Or maybe not, people should be OK with the file being deleted?) In this latter case, would there be an option just to “unsetup” the profile without deleting the .aiida file?

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [December 13, 2023, 8:58pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/7 "2023-12-13T20:58:26Z")

</div>

> [@giovannipizzi](#):
>
> @sphuber one question - when you do verdi profile delete, will it also delete the .aiida file? To be consistent with the usual delete behaviour, I think it should, on the other hand it might be unexpected? (Or maybe not, people should be OK with the file being deleted?) In this latter case, would there be an option just to “unsetup” the profile without deleting the .aiida file?

Yes, there is the `--delete-storage/--no-delete-storage` option that is turned on by default, but can be switched off. When passing `--no-delete-storage` the archive is kept and the profile is just removed from the config.

---

<div class="post-metadata">

**Author:** ![mbercx](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/mbercx/32/345_2.png) [@mbercx](https://aiida.discourse.group/u/mbercx)\
**Post date:** [December 13, 2023, 9:04pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/8 "2023-12-13T21:04:27Z")

</div>

> [@sphuber](#):
>
> Yes, there is the `--delete-storage/--no-delete-storage` option that is turned on by default,

I think the current default is to _not_ delete the storage right?

> <https://github.com/sphuber/aiida-core/blob/891072f5c9e8423556e2b411a250e66ef95f4f28/aiida/cmdline/commands/cmd_profile.py#L139-L144>

At least I think this _should_ be the default, else it’d indeed be risky that users create a temp profile from an archive, delete it and also accidentally delete the archive.

But let’s continue that discussion [on the PR](https://github.com/aiidateam/aiida-core/pull/6224).

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [December 13, 2023, 10:38pm UTC](https://aiida.discourse.group/t/developing-inside-aiidalab-docker-environment/185/9 "2023-12-13T22:38:55Z")

</div>

I made a mistake, it is _off_ by default, so a user has to explicitly switch it on for the data to be deleted.
