Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit ea6bb0f

Browse files
committed
Added support for docker run --init
If you use this parameter to start your container, dumb-init is not used at all. This deprecates the use of dumb-init, which in turn might be removed some time in the future. Also cleaned up some examples in the README.
1 parent 19fa4b0 commit ea6bb0f

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ How to use
1818

1919
The most common use-case is to provide DHCP service to the host network of
2020
the machine running Docker. For that you need to create a configuration for
21-
the DHCP server, start the container with the `--net=host` docker run
21+
the DHCP server, start the container with the `--net host` docker run
2222
option and specify the network interface you want to provide DHCP service
2323
on.
2424

@@ -27,7 +27,7 @@ on.
2727
network interface. If you need assistance, you can run
2828
`docker run -it --rm networkboot/dhcpd man dhcpd.conf` for a description
2929
of the configuration file syntax.
30-
3. Run `docker run -it --rm --net=host -v "$(pwd)/data":/data networkboot/dhcpd eth0`.
30+
3. Run `docker run -it --rm --init --net host -v "$(pwd)/data":/data networkboot/dhcpd eth0`.
3131
`dhcpd` will automatically start and display its logs on the console.
3232
You can press Ctrl-C to terminate the server.
3333

@@ -42,7 +42,7 @@ server as the same user that owns the `data` folder. This ensures that the
4242
permissions on the files inside the `data` folder is kept consistent. If
4343
the `data` folder is owned by root, dhcpd is run as the normal dhcpd user.
4444

45-
If you forget to run the docker container with the `--net=host` option a
45+
If you forget to run the docker container with the `--net host` option a
4646
warning will be emitted informing you that you've probably forgotten it.
4747

4848
If a `/data` volume is not provided with a `dhcpd.conf` inside it, the

run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
pushd $(dirname $0) >/dev/null
33
data_dir="$(pwd)/data"
4-
docker run -ti --rm --net host -v "$data_dir":/data networkboot/dhcpd "$@"
4+
docker run -ti --rm --init --net host -v "$data_dir":/data networkboot/dhcpd "$@"
55
popd >/dev/null

util/entrypoint.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
set -e
44

55

6-
init="/usr/bin/dumb-init"
6+
# Support docker run --init parameter which obsoletes the use of dumb-init,
7+
# but support dumb-init for those that still use it without --init
8+
if [ -x "/dev/init" ]; then
9+
run="exec"
10+
else
11+
run="exec /usr/bin/dumb-init --"
12+
fi
713

814
# Single argument to command line is interface name
915
if [ $# -eq 1 -a -n "$1" ]; then
@@ -63,8 +69,8 @@ if [ -n "$IFACE" ]; then
6369
echo "You must add the 'docker run' option '--net=host' if you want to provide DHCP service to the host network."
6470
fi
6571

66-
exec $init -- /usr/sbin/dhcpd -4 -f -d --no-pid -cf "$data_dir/dhcpd.conf" -lf "$data_dir/dhcpd.leases" $IFACE
72+
$run /usr/sbin/dhcpd -4 -f -d --no-pid -cf "$data_dir/dhcpd.conf" -lf "$data_dir/dhcpd.leases" $IFACE
6773
else
6874
# Run another binary
69-
exec $init -- "$@"
75+
$run "$@"
7076
fi

0 commit comments

Comments
 (0)