Now that we have a development container setup in place, we can manipulate and use this setup to run our code. This tutorial will cover some basic commands, entering and exiting containers, and shutting down and launching them!
Now that your dev container is built, let's get familiar with some dev container basics.
Our dev containers use Docker. Docker is a container management tool that allows you to download and store "images" that can be built and used as "containers". Images are effectively small installation objects that contain all the necessary components to set up a specific container with a specific environment. Containers are effectively small environments that have just the base essentials to run all the development tooling that is required. Containers are built from images.
Here are some basic commands that will be useful to use in terminal:
docker images
: lists all available images being tracked by Dockerdocker ps
: lists all running containers along with their statusdocker ps -a
: lists all containers even if they are not runningOnce your container is built, you will be able to use it for your research or programming. The development container setups provided by the department should be a sufficient starting point. More advanced setups are discussed in the Dev Container Customization tutorial. Here, we will show how to start up, attach, detach, and stop a container.
To start a container, you can do one of the following:
ctrl
/⌘ + shift
+ p
or F1
) search for "Reopen in Container":To detach from a running container, click on the bottom left remotes button or using the keyboard shortcut (ctrl
/⌘ + shift
+ p
or F1
) search for "Reopen Folder in SSH" or "Reopen Folder Locally".
Clicking this will detach you from the running container. However, it will not close the container.
To reattach to a running container, click on the bottom left remotes button or using the keyboard shortcut (ctrl
/⌘ + shift
+ p
or F1
) search for "Attach to Running Container...":
From there, you will be given an option to select one of your running containers.
To stop a running container run the following commands:
docker ps
: run this to figure out which container(s) are running. You will see a "NAMES" category, this will be the container name to use in the next command.docker container stop <container_name>
: replace <container_name>
with the previous commands output.Running these 2 commands will stop this container as well as any code or services running in it.
Docker comes with a swathe of terminal commands to manage containers. More advanced commands will be added in future tutorials.
File management in development containers is made simple through VS Code. For all intents and purposes, file management in dev containers is no different than in local or SSH setups.
In essence:
scp
or sftp
commands or a GUI tool like WinSCP to transfer between remote <-> remote.For more information, see the File Management wiki entry.
With the default setup, it is possible to run Python and R via
These tools allow for users to run their code and programs while inside the container. It is recommended to use notebooks (RMarkdown or Jupyter) to run jobs that are possible to complete during a single session.
However, for long running jobs that take many hours or potentially even days to run, it is recommended to use alternative measures to complete these jobs without needing to stay in a dev container session. More information on this can be found in the Job Management wiki entry.