mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-05 06:15:30 +00:00
Switch runc and containerd startup to be entirely Go
At present they use a small shared function called "prepare" that does the read-write remounts, that I will switch to doing overlay mounts soon. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
@@ -23,6 +23,7 @@ RUN cp bin/containerd bin/ctr bin/containerd-shim /usr/bin/
|
||||
ADD cmd /go/src/cmd
|
||||
RUN cd /go/src/cmd/service && ./skanky-vendor.sh $GOPATH/src/github.com/containerd/containerd
|
||||
RUN go-compile.sh /go/src/cmd/service
|
||||
RUN mkdir -p /etc/init.d && ln -s /usr/bin/service /etc/init.d/020-containerd
|
||||
|
||||
WORKDIR /
|
||||
COPY . .
|
||||
@@ -33,4 +34,5 @@ WORKDIR /
|
||||
COPY --from=alpine /usr/bin/containerd /usr/bin/ctr /usr/bin/containerd-shim /go/bin/service /usr/bin/
|
||||
COPY --from=alpine /etc/containerd/config.toml /etc/containerd/
|
||||
COPY --from=alpine /usr/share/zoneinfo/UTC /etc/localtime
|
||||
COPY --from=alpine /etc/init.d/ /etc/init.d/
|
||||
COPY etc etc/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
IMAGE=containerd
|
||||
NETWORK=1
|
||||
DEPS=$(wildcard etc/init.d/*) $(wildcard cmd/service/*.go) etc/containerd/config.toml
|
||||
DEPS=$(wildcard cmd/service/*.go) etc/containerd/config.toml
|
||||
|
||||
include ../package.mk
|
||||
|
||||
@@ -66,9 +66,8 @@ func main() {
|
||||
|
||||
args := flag.Args()
|
||||
if len(args) < 1 {
|
||||
fmt.Printf("Please specify a command.\n\n")
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
systemInitCmd(args)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
|
||||
21
pkg/containerd/cmd/service/prepare.go
Normal file
21
pkg/containerd/cmd/service/prepare.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
// Please note this file is shared between pkg/runc and pkg/containerd
|
||||
// Update it in both places if you make changes
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func prepare(path string) error {
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
if err := syscall.Mount(rootfs, rootfs, "", syscall.MS_BIND, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
// remount rw
|
||||
if err := syscall.Mount("", rootfs, "", syscall.MS_REMOUNT, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -58,6 +58,10 @@ func startCmd(args []string) {
|
||||
func start(service, sock, path, dumpSpec string) (string, uint32, string, error) {
|
||||
rootfs := filepath.Join(path, service, "rootfs")
|
||||
|
||||
if err := prepare(filepath.Join(path, service)); err != nil {
|
||||
return "", 0, "preparing rootfs", err
|
||||
}
|
||||
|
||||
client, err := containerd.New(sock)
|
||||
if err != nil {
|
||||
return "", 0, "creating containerd client", err
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# start service containers
|
||||
|
||||
if [ -d /containers/services ]
|
||||
then
|
||||
for f in $(find /containers/services -mindepth 1 -maxdepth 1 | sort)
|
||||
do
|
||||
/bin/mount --bind "$f/rootfs" "$f/rootfs"
|
||||
mount -o remount,rw "$f/rootfs"
|
||||
done
|
||||
fi
|
||||
|
||||
service system-init
|
||||
Reference in New Issue
Block a user