diff --git a/sysinit/sysinit.go b/sysinit/sysinit.go index 2dc5967dc6..ad97439450 100644 --- a/sysinit/sysinit.go +++ b/sysinit/sysinit.go @@ -32,7 +32,7 @@ func setupHostname(args *DockerInitArgs) error { if hostname == "" { return nil } - return syscall.Sethostname([]byte(hostname)) + return setHostname(hostname) } // Setup networking diff --git a/sysinit/sysinit_darwin.go b/sysinit/sysinit_darwin.go new file mode 100644 index 0000000000..64566afb3c --- /dev/null +++ b/sysinit/sysinit_darwin.go @@ -0,0 +1,5 @@ +package sysinit + +func setHostname(hostname string) error { + panic("Not supported on darwin") +} diff --git a/sysinit/sysinit_linux.go b/sysinit/sysinit_linux.go new file mode 100644 index 0000000000..d18d2fab8b --- /dev/null +++ b/sysinit/sysinit_linux.go @@ -0,0 +1,9 @@ +package sysinit + +import ( + "syscall" +) + +func setHostname(hostname string) error { + return syscall.Sethostname([]byte(hostname)) +}