Skip to content

Commit b019d9a

Browse files
committed
networking: document --netns-path
Add documentation for --netns-path network namespace joins. While we are here, start a fresh new in 4.2 page. Fixes #246
1 parent dc979ed commit b019d9a

File tree

3 files changed

+64
-68
lines changed

3 files changed

+64
-68
lines changed

index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Getting Started & Background Information
1919
.. toctree::
2020
:maxdepth: 2
2121

22-
What's New in {Singularity} 4.1 <new>
22+
What's New in {Singularity} 4.2 <new>
2323

2424
Introduction to {Singularity} <introduction>
2525
Quick Start <quick_start>

networking.rst

+52-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Network virtualization
66

77
.. _sec:networking:
88

9-
{Singularity} provides full integration with `cni
10-
<https://github.com/containernetworking/cni>`_ , to make network
11-
virtualization easy. The following options can be used with the the
12-
action commands (``exec``, ``run``, and ``shell``) to create and
13-
configure a virtualized network for a container.
9+
{Singularity}'s native mode provides full integration with `CNI
10+
<https://github.com/containernetworking/cni>`_ , and the ability to join an
11+
existing network namespace, to make network virtualization easy. The following
12+
options can be used with the the action commands (``exec``, ``run``, and
13+
``shell``) to create and configure a virtualized network for a container.
1414

1515
.. note::
1616

1717
Many of these options are available only to the ``root`` user by
1818
default. Unrestricted ability to configure networking for containers
1919
would allow users to affect networking on the host, or in a cluster.
2020

21-
{Singularity} 3.8 allows the administrator to permit a list of
21+
{Singularity} allows the administrator to permit a list of
2222
unprivileged users and/or groups to use specified network
2323
configurations. This is accomplished through settings in
2424
``singularity.conf``. See the administrator guide for details.
@@ -56,6 +56,52 @@ hostname within the container.
5656
$ sudo singularity exec --hostname hal-9000 my_container.sif hostname
5757
hal-9000
5858
59+
.. _sec:netns-path:
60+
61+
****************
62+
``--netns-path``
63+
****************
64+
65+
*New in {Singularity} 4.2*
66+
67+
Passing the ``--netns-path`` flag with a path to an existing network namespace
68+
will cause the container to join that namespace.
69+
70+
For example, a network namespace can be created with the ``ip`` command on the
71+
host, and then a container started that will run within this namespace:
72+
73+
.. example::
74+
75+
# Create an example named network namespace
76+
$ sudo ip netns add my-net
77+
78+
# Add a dummy network interface to the network namespace
79+
$ sudo ip netns exec my-net ip link add dummy0 type dummy
80+
81+
# Run a container in the network namespace
82+
$ sudo singularity run --netns-path /run/netns/my-net library://alpine
83+
INFO: Using cached image
84+
Singularity> ip a
85+
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN qlen 1000
86+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
87+
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 1000
88+
link/ether 92:5c:ab:ab:d3:d0 brd ff:ff:ff:ff:ff:ff
89+
Singularity>
90+
91+
Note that the ``ip a`` command run inside the container shows the ``dummy0``
92+
interface we added to the ``my-net`` network namespace.
93+
94+
The root user can join any network namespace with ``--netns-path``.
95+
96+
A non-root user can only join a network namespace if the following are true:
97+
98+
* The path of the network namespace is listed in the ``allow netns paths``
99+
directive in ``singularity.conf``, which is typically managed by the system
100+
administrator.
101+
* The user is listed in the ``allow net users`` directive in ``singularity.conf``,
102+
or the user is a member of a group listed in the ``allow net groups`` directive
103+
in ``singularity.conf``.
104+
59105
*********
60106
``--net``
61107
*********

new.rst

+11-61
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,24 @@
11
.. _whats_new:
22

33
###############################
4-
What's New in {Singularity} 4.1
4+
What's New in {Singularity} 4.2
55
###############################
66

7-
This section highlights important changes and new features in {Singularity} 4.1
7+
This section highlights important changes and new features in {Singularity} 4.2
88
that are of note to users. See also the "What's New" section in the Admin Guide
99
for administrator-facing changes.
1010

1111
If you are upgrading from a 3.x version of {Singularity} we recommend also
1212
reviewing the `"What's New" section for 4.0
1313
<https://docs.sylabs.io/guides/4.0/user-guide/new.html>`__.
1414

15-
********
16-
OCI-mode
17-
********
15+
*******
16+
Runtime
17+
*******
1818

19-
- Singularity will now :ref:`build OCI-SIF images from Dockerfiles
20-
<dockerfile>`, if the ``--oci`` flag is used with the ``build`` command.
21-
Provide a Dockerfile as the final argument to ``build``, instead of a
22-
Singularity definition (.def) file. Supports ``--build-arg`` /
23-
``--build-arg-file`` options, ``--arch`` for cross-architecture builds,
24-
`--authfile` and other authentication options, and more. Dockerfile builds are
25-
not available on EL7 / SLES12 distributions.
26-
- `Docker-style SCIF containers <https://sci-f.github.io/tutorial-preview-install>`__
27-
are now supported. If the entrypoint of an OCI container is the ``scif``
28-
executable, then the ``run`` / ``exec`` / ``shell`` commands in ``--oci`` mode
29-
can be given the ``--app <appname>`` flag, and will automatically invoke the
30-
relevant SCIF command.
31-
- `Multi layer OCI-SIF images <sec:multi_layer_oci_sif>` can now be created
32-
using a new ``--keep-layers`` flag, for the ``pull`` and ``run/shell/exec``
33-
commands. This allows individual layers to be preserved when an OCI-SIF image
34-
is created from an OCI source. Multi layer OCI-SIF images can be run with
35-
SingularityCE 4.1 and later.
36-
37-
***********
38-
CLI Changes
39-
***********
40-
41-
- The ``registry login`` and ``registry logout`` commands now support an
42-
``--authfile <path>`` flag, which causes the OCI credentials to be written to
43-
/ removed from a custom file located at ``<path>`` instead of the default
44-
location (``$HOME/.singularity/docker-config.json``). The commands ``pull``,
45-
``push``, ``run``, ``exec``, ``shell``, and ``instance start`` can now also be
46-
passed a ``--authfile <path>`` option, to read OCI registry credentials from
47-
this custom file.
48-
- A new `--tmp-sandbox` flag has been added to the `run / shell / exec /
49-
instance start` commands. This will force Singularity to extract a container
50-
to a temporary sandbox before running it, when it would otherwise perform a
51-
kernel or FUSE mount.
52-
53-
************************
54-
Runtime Behavior Changes
55-
************************
56-
57-
- In native mode, SIF/SquashFS container images will now be mounted with
58-
squashfuse when kernel mounts are disabled in ``singularity.conf``, or cannot
59-
be used (non-setuid / user namespace workflow). If the FUSE mount fails,
60-
Singularity will fall back to extracting the container to a temporary sandbox
61-
in order to run it.
62-
- In native mode, bare extfs container images will now be mounted with
63-
``fuse2fs`` when kernel mounts are disabled in ``singularity.conf``, or cannot
64-
be used (non-setuid / user namespace workflow).
65-
66-
************
67-
Deprecations
68-
************
69-
70-
- The experimental ``--sif-fuse`` flag, and ``sif fuse`` directive in
71-
``singularity.conf`` are deprecated. The flag and directive were used to
72-
enable experimental mounting of SIF/SquashFS container images with FUSE in
73-
prior versions of Singularity. From 4.1, FUSE mounts are used automatically
74-
when kernel mounts are disabled / not available.
19+
- The new ``--netns-path`` flag takes a path to a network namespace to join when
20+
starting a container. The root user may join any network namespace. An
21+
unprivileged user can only join a network namespace specified in the new
22+
allowed ``netns paths directive`` in ``singularity.conf``, if they are also
23+
listed in ``allow net users`` / ``allow net groups``. Not currently supported
24+
with ``--fakeroot``, or in ``--oci`` mode. See :ref:`sec:netns-path`.

0 commit comments

Comments
 (0)