@@ -288,7 +288,7 @@ creating images that can be run using {Singularity}'s :ref:`OCI mode
288288
289289 $ singularity build --oci ./debian.oci.sif ./Dockerfile
290290 INFO: Did not find usable running buildkitd daemon; spawning our own.
291- INFO: cfg.Root for buildkitd: /home/omer /.local/share/buildkit
291+ INFO: cfg.Root for buildkitd: /home/myuser /.local/share/buildkit
292292 INFO: Using crun runtime for buildkitd daemon.
293293 INFO: running buildkitd server on /run/user/1000/buildkit/buildkitd-0179484509442521.sock
294294 [+] Building 4.3s (5/5)
@@ -378,7 +378,7 @@ that is piped through ``stdin``. The following example demonstrates both:
378378
379379 $ singularity build --oci ./lolcow.oci.sif ./Dockerfile
380380 INFO: Did not find usable running buildkitd daemon; spawning our own.
381- INFO: cfg.Root for buildkitd: /home/omer /.local/share/buildkit
381+ INFO: cfg.Root for buildkitd: /home/myuser /.local/share/buildkit
382382 INFO: Using crun runtime for buildkitd daemon.
383383 INFO: running buildkitd server on /run/user/1000/buildkit/buildkitd-8961170237105250.sock
384384 [+] Building 15.1s (9/9)
@@ -445,13 +445,72 @@ complete. This ephemeral build daemon is based on `moby/buildkit
445445
446446.. note ::
447447
448- Launching the ephemeral `` buildkitd `` daemon requires a system with
448+ Launching the ephemeral build daemon requires a system with
449449 :ref: `user namespace support <setuid_and_userns >` as well as ``crun `` /
450450 ``runc `` installed. These are independently required for using
451451 {Singularity}'s :ref: `OCI mode <oci_sysreq >`. See the `Admin Guide
452452 <https://sylabs.io/guides/{adminversion}/admin-guide/> `__ for more
453453 information on these system requirements.
454454
455+ The `build context <https://docs.docker.com/build/building/context/ >`__ for
456+ Dockerfile builds using {Singularity} is always the current working directory.
457+ Therefore, if you want to have the build context set to a different directory
458+ than the one your Dockerfile is in, all you have to do is run {Singularity}
459+ *from the desired context dir *, and provide a relative or absolute path to the
460+ Dockerfile:
461+
462+ .. code :: console
463+
464+ $ pwd
465+ /home/myuser/tmp/my_context_dir
466+
467+ $ ls
468+ some_file
469+
470+ $ cat some_file
471+ Some text.
472+
473+ $ cat ../Dockerfile
474+ From alpine
475+ ADD some_file /
476+ CMD cat /some_file
477+
478+ $ singularity build --oci ./container.oci.sif ../Dockerfile
479+ INFO: Did not find usable running buildkitd daemon; spawning our own.
480+ INFO: cfg.Root for buildkitd: /home/myuser/.local/share/buildkit
481+ INFO: Using "crun" runtime for buildkitd daemon.
482+ INFO: running buildkitd server on /run/user/1000/buildkit/buildkitd-8519770128063388.sock
483+ [+] Building 1.3s (6/7)
484+ [+] Building 1.4s (7/7) FINISHED
485+ => [internal] load build definition from Dockerfile 0.0s
486+ => => transferring dockerfile: 143B 0.0s
487+ => [internal] load metadata for docker.io/library/alpine:latest 1.3s
488+ => [internal] load .dockerignore 0.0s
489+ => => transferring context: 2B 0.0s
490+ => [internal] load build context 0.0s
491+ => => transferring context: 88B 0.0s
492+ => [1/2] FROM docker.io/library/alpine:latest@sha256:eece025e432 0.0s
493+ => => resolve docker.io/library/alpine:latest@sha256:eece025e432 0.0s
494+ => CACHED [2/2] ADD some_file / 0.0s
495+ => exporting to docker image format 0.0s
496+ => => exporting layers 0.0s
497+ => => exporting manifest sha256:78c2cbf8ea2441c7a3d75f80bd0660ef 0.0s
498+ => => exporting config sha256:58e9a24e9242901475f317e201185cbf10 0.0s
499+ => => sending tarball 0.0s
500+ Getting image source signatures
501+ Copying blob 96526aa774ef done |
502+ Copying blob 15061a177792 done |
503+ Copying config 3d12fd8035 done |
504+ Writing manifest to image destination
505+ INFO: Converting OCI image to OCI-SIF format
506+ INFO: Squashing image to single layer
507+ INFO: Writing OCI-SIF image
508+ INFO: Cleaning up.
509+ INFO: Build complete: ./container.oci.sif
510+
511+ $ singularity run --oci ./container.oci.sif
512+ Some text.
513+
455514 Additional features
456515===================
457516
@@ -476,7 +535,7 @@ following to build a container image for the 64-bit ARM architecure:
476535
477536 $ singularity build --arch arm64 --oci ./alpine.oci.sif ./Dockerfile.alpine
478537 INFO: Did not find usable running buildkitd daemon; spawning our own.
479- INFO: cfg.Root for buildkitd: /home/omer /.local/share/buildkit
538+ INFO: cfg.Root for buildkitd: /home/myuser /.local/share/buildkit
480539 INFO: Using "crun" runtime for buildkitd daemon.
481540 INFO: running buildkitd server on /run/user/1000/buildkit/buildkitd-4747966236261602.sock
482541 [+] Building 0.6s (1/2)
0 commit comments