@@ -3,26 +3,34 @@ FROM microsoft/dotnet-nightly:2.0-runtime-deps
3
3
# The "container" environment variable is read by systemd.
4
4
ENV container=docker
5
5
6
- # This is required by systemd and won't work without "dotnet run --privileged".
7
- VOLUME ["/sys/fs/cgroup" ]
6
+ # Install and configure systemd which requires dbus for graceful shutdown.
7
+ RUN ["apt-get" , "-o" , "Acquire::Check-Valid-Until=false" , "update" ]
8
+ RUN ["apt-get" , "install" , "-y" , "--no-install-recommends" , "systemd-sysv" ]
9
+
10
+ # Set proper systemd default target.
11
+ RUN ["systemctl" , "set-default" , "multi-user.target" ]
12
+
13
+ # Remove non-vital systemd services.
14
+ RUN ["find" , "/etc/systemd/system" , "/lib/systemd/system" , \
15
+ "-path" , "*.wants/*" , \
16
+ "-not" , "-name" , "*systemd-journald*" , \
17
+ "-not" , "-name" , "*systemd-tmpfiles*" , \
18
+ "-not" , "-name" , "*systemd-user-sessions*" , \
19
+ "-delete" ]
20
+
21
+ # Copy .NET installation.
22
+ ADD .dotnet/ /usr/share/dotnet/
23
+ RUN ["ln" , "-s" , "/usr/share/dotnet/dotnet" , "/usr/bin/dotnet" ]
8
24
9
25
# Create activate-kestrel.service to launch the "publish" app on new requests to 8080.
10
26
EXPOSE 8080
11
- ADD .dotnet/ /usr/share/dotnet/
12
27
ADD publish/ /publish/
13
- ADD activate-kestrel.socket /etc/systemd/system/activate-kestrel.socket
14
28
ADD activate-kestrel.service /etc/systemd/system/activate-kestrel.service
29
+ ADD activate-kestrel.socket /etc/systemd/system/activate-kestrel.socket
15
30
16
- # Install and configure systemd which requires dbus for graceful shutdown.
17
- RUN ["apt-get" , "-o" , "Acquire::Check-Valid-Until=false" , "update" ]
18
- RUN ["apt-get" , "install" , "-y" , "dbus" ]
19
- RUN ["systemctl" , "mask" , "getty.target" , "console-getty.service" ]
20
- RUN ["cp" , "/lib/systemd/system/dbus.service" , "/etc/systemd/system/" ]
21
- RUN ["sed" , "-i" , "s/OOMScoreAdjust=-900//" , "/etc/systemd/system/dbus.service" ]
22
-
23
- # Automatically start activate-kestrel.service on boot.
24
- RUN ["ln" , "-s" , "/usr/share/dotnet/dotnet" , "/usr/bin/dotnet" ]
25
- RUN ["ln" , "-s" , "/usr/lib/systemd/system/activate-kestrel.service" , "/etc/systemd/system/multi-user.target.wants/activate-kestrel.service" ]
31
+ # Automatically start activate-kestrel.socket on boot.
32
+ RUN ["systemctl" , "enable" , "activate-kestrel.socket" ]
26
33
27
- # Launch systemd.
28
- CMD ["/sbin/init" ]
34
+ # Launch systemd, with workaround for docker/docker#27202, technique based on comments from docker/docker#9212.
35
+ CMD ["/bin/bash" , "-c" , "exec /sbin/init --log-target=journal 3>&1" ]
36
+ STOPSIGNAL SIGRTMIN+3
0 commit comments