Skip to content

Commit 7c113e3

Browse files
authored
Create 04_docker_images.mdx
1 parent c308580 commit 7c113e3

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Using Docker Images with Apptainer
2+
3+
So far, we have used container images that are already available on Torch under `/share/apps/images`.
4+
5+
In practice, you may also want to run software that is not provided by the cluster. Apptainer can pull images directly from Docker registries and convert them into the Apptainer SIF format.
6+
7+
For example, we can pull an official PyTorch image from Docker Hub:
8+
9+
```bash
10+
apptainer pull pytorch.sif docker://pytorch/pytorch:latest
11+
```
12+
13+
During the pull process, Apptainer downloads the Docker image layers and converts them into a single SIF image:
14+
15+
```text
16+
INFO: Converting OCI blobs to SIF format
17+
INFO: Starting build...
18+
INFO: Fetching OCI image...
19+
...
20+
INFO: Creating SIF file...
21+
```
22+
23+
The output shows that Apptainer is downloading the Docker image layers and converting them into a single SIF image. Once the conversion completes, the resulting SIF file can be used without Docker.
24+
When the command completes, a new image named `pytorch.sif` will be created in the current directory.
25+
26+
You can verify that the image exists:
27+
28+
```bash
29+
ls -lh pytorch.sif
30+
```
31+
32+
The image can now be used like any other Apptainer image.
33+
34+
For example:
35+
36+
```bash
37+
apptainer exec pytorch.sif python --version
38+
```
39+
40+
or
41+
42+
```bash
43+
apptainer exec pytorch.sif python -c "import torch; print(torch.__version__)"
44+
```

0 commit comments

Comments
 (0)