Skip to content

Development within Containers

Anderson Chauphan edited this page May 6, 2024 · 4 revisions

How to get your code into a container

Using VSCode with a container

Customizing Containers

Adding tools to a container

  • YUM - You are root within a container, so you may add anything from the UBI yum repositories
    • yum install vim
  • Spack - Our containers use Spack to set up most of the third-party software, so adding any desired package to the active Spack environment will allow you to install it
    • spack install --add ddt
  • Caveat: A container is ephemeral. Once the container is stopped and removed, you will lose the installed software. If you wish to add software in a persistent manner
    • Contact [email protected] to request additional software be added to container recipes, which will add them to the images that are published in the registry
    • [TODO: Add instructions for layering an image on top of one of ours (maybe in the basics section?)]

Developing with Persistent Data in Containers

As mentioned above, due to containers being ephemeral instances, any files created, modified, or removed within the container will be lost once the container instance is shut down. This can be a pain if you are trying to use a container as a development environment as you may need to utilize the same files between container instances or between the container and host machine.

With most container engines there are two solutions to this problem, creating a container volume visible on the host machine, or bind mounting a directory from the host machine to the container directly.

For a more in-depth explanation of these two solutions, see the following recommended documentation:

In this case, we will recommend bind mounting as it is the more simpler approach. All that is required is an absolute path to a workspace directory on the host machine.

docker run --rm -it --mount type=bind,src=${HOME}/Trilinos,dst=/root/Trilinos <some_image_here>

In this example, ${HOME}/Trilinos is the directory on the host machine we want to make visible inside the container at its /root/Trilinos path. Any files created, modified, or removed here will persist through the host machine and through future containers launched with the same mounted paths.

Clone this wiki locally