Skip to content

ContainerizedCode: Add support for running codes within Docker containers #5818

@sphuber

Description

@sphuber

Currently the ContainerizedCode implementation supports certain container technologies, such as Singularity and Sarus. These are technologies that are often employed by high-performance computing centers, but users will typically not be familiar with running this on their workstations. Docker is a more common option, but is not yet supported. Providing support for Docker would make a huge step in increasing the provenance of AiiDA even more, as now the compute environment of CalcJobs is not stored at all.

At least for the most minimal use case, one single change should be sufficient to enable Docker support. The way a command within a docker container should be invoked is as follows:

"docker" "run" "-i" "-v" "$PWD:/workdir:rw" "-w" "/workdir" "{image_name}" "sh" "-c" "{executable} {arguments} > "'"'"{stdout}"'"'" "

The most important part is that the executable, command line arguments and the redirection of file streams (stdin, stderr and stdout) should all be wrapped in double quotes to form a single argument to the sh -c invocation.

It is not possible to do this with the current API provided by aiida-core. A solution had already been proposed by @unkcpz in #5507 by adding another attribute to the ContainerizedCode called escape_exec_line which would be False by default. When set to True it would instruct Scheduler plugins to wrap all arguments after the computer command line arguments in double quotes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions