mirror of
https://github.com/rancher/os.git
synced 2025-07-19 17:39:04 +00:00
Merge pull request #1332 from joshwget/move-in-netconf-and-dfs
Move in code from netconf and docker-from-scratch
This commit is contained in:
commit
5ecbf19aa8
@ -36,9 +36,9 @@ import (
|
||||
"github.com/coreos/coreos-cloudinit/datasource/proc_cmdline"
|
||||
"github.com/coreos/coreos-cloudinit/datasource/url"
|
||||
"github.com/coreos/coreos-cloudinit/pkg"
|
||||
"github.com/rancher/netconf"
|
||||
"github.com/rancher/os/cmd/cloudinitsave/gce"
|
||||
rancherConfig "github.com/rancher/os/config"
|
||||
"github.com/rancher/os/netconf"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
@ -231,8 +231,8 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
|
||||
}
|
||||
|
||||
func enableDoLinkLocal() {
|
||||
err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{
|
||||
Interfaces: map[string]netconf.InterfaceConfig{
|
||||
err := netconf.ApplyNetworkConfigs(&rancherConfig.NetworkConfig{
|
||||
Interfaces: map[string]rancherConfig.InterfaceConfig{
|
||||
"eth0": {
|
||||
IPV4LL: true,
|
||||
},
|
||||
|
@ -12,11 +12,11 @@ import (
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/packethost/packngo/metadata"
|
||||
"github.com/rancher/netconf"
|
||||
rancherConfig "github.com/rancher/os/config"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/netconf"
|
||||
)
|
||||
|
||||
func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
func enablePacketNetwork(cfg *config.RancherConfig) {
|
||||
bootStrapped := false
|
||||
for _, v := range cfg.Network.Interfaces {
|
||||
if v.Address != "" {
|
||||
@ -40,7 +40,7 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
return
|
||||
}
|
||||
|
||||
bondCfg := netconf.InterfaceConfig{
|
||||
bondCfg := config.InterfaceConfig{
|
||||
Addresses: []string{},
|
||||
BondOpts: map[string]string{
|
||||
"lacp_rate": "1",
|
||||
@ -51,11 +51,11 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
"mode": "4",
|
||||
},
|
||||
}
|
||||
netCfg := netconf.NetworkConfig{
|
||||
Interfaces: map[string]netconf.InterfaceConfig{},
|
||||
netCfg := config.NetworkConfig{
|
||||
Interfaces: map[string]config.InterfaceConfig{},
|
||||
}
|
||||
for _, iface := range m.Network.Interfaces {
|
||||
netCfg.Interfaces["mac="+iface.Mac] = netconf.InterfaceConfig{
|
||||
netCfg.Interfaces["mac="+iface.Mac] = config.InterfaceConfig{
|
||||
Bond: "bond0",
|
||||
}
|
||||
}
|
||||
@ -80,24 +80,24 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
b, _ := yaml.Marshal(netCfg)
|
||||
logrus.Debugf("Generated network config: %s", string(b))
|
||||
|
||||
cc := rancherConfig.CloudConfig{
|
||||
Rancher: rancherConfig.RancherConfig{
|
||||
cc := config.CloudConfig{
|
||||
Rancher: config.RancherConfig{
|
||||
Network: netCfg,
|
||||
},
|
||||
}
|
||||
|
||||
// Post to phone home URL on first boot
|
||||
if _, err = os.Stat(rancherConfig.CloudConfigNetworkFile); err != nil {
|
||||
if _, err = os.Stat(config.CloudConfigNetworkFile); err != nil {
|
||||
if _, err = http.Post(m.PhoneHomeURL, "application/json", bytes.NewReader([]byte{})); err != nil {
|
||||
logrus.Errorf("Failed to post to Packet phone home URL: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(path.Dir(rancherConfig.CloudConfigNetworkFile), 0700); err != nil {
|
||||
logrus.Errorf("Failed to create directory for file %s: %v", rancherConfig.CloudConfigNetworkFile, err)
|
||||
if err := os.MkdirAll(path.Dir(config.CloudConfigNetworkFile), 0700); err != nil {
|
||||
logrus.Errorf("Failed to create directory for file %s: %v", config.CloudConfigNetworkFile, err)
|
||||
}
|
||||
|
||||
if err := rancherConfig.WriteToFile(cc, rancherConfig.CloudConfigNetworkFile); err != nil {
|
||||
logrus.Errorf("Failed to save config file %s: %v", rancherConfig.CloudConfigNetworkFile, err)
|
||||
if err := config.WriteToFile(cc, config.CloudConfigNetworkFile); err != nil {
|
||||
logrus.Errorf("Failed to save config file %s: %v", config.CloudConfigNetworkFile, err)
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
|
||||
"github.com/docker/libnetwork/resolvconf"
|
||||
"github.com/rancher/netconf"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/docker"
|
||||
"github.com/rancher/os/hostname"
|
||||
"github.com/rancher/os/netconf"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"github.com/coreos/coreos-cloudinit/config"
|
||||
"github.com/docker/engine-api/types"
|
||||
composeConfig "github.com/docker/libcompose/config"
|
||||
"github.com/rancher/netconf"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -112,8 +111,8 @@ type RancherConfig struct {
|
||||
Disable []string `yaml:"disable,omitempty"`
|
||||
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
||||
Modules []string `yaml:"modules,omitempty"`
|
||||
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
||||
DefaultNetwork netconf.NetworkConfig `yaml:"default_network,omitempty"`
|
||||
Network NetworkConfig `yaml:"network,omitempty"`
|
||||
DefaultNetwork NetworkConfig `yaml:"default_network,omitempty"`
|
||||
Repositories Repositories `yaml:"repositories,omitempty"`
|
||||
Ssh SshConfig `yaml:"ssh,omitempty"`
|
||||
State StateConfig `yaml:"state,omitempty"`
|
||||
@ -168,6 +167,39 @@ type DockerConfig struct {
|
||||
Exec bool `yaml:"exec,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkConfig struct {
|
||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||
Dns DnsConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||
HttpProxy string `yaml:"http_proxy,omitempty"`
|
||||
HttpsProxy string `yaml:"https_proxy,omitempty"`
|
||||
NoProxy string `yaml:"no_proxy,omitempty"`
|
||||
}
|
||||
|
||||
type InterfaceConfig struct {
|
||||
Match string `yaml:"match,omitempty"`
|
||||
DHCP bool `yaml:"dhcp,omitempty"`
|
||||
DHCPArgs string `yaml:"dhcp_args,omitempty"`
|
||||
Address string `yaml:"address,omitempty"`
|
||||
Addresses []string `yaml:"addresses,omitempty"`
|
||||
IPV4LL bool `yaml:"ipv4ll,omitempty"`
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
GatewayIpv6 string `yaml:"gateway_ipv6,omitempty"`
|
||||
MTU int `yaml:"mtu,omitempty"`
|
||||
Bridge string `yaml:"bridge,omitempty"`
|
||||
Bond string `yaml:"bond,omitempty"`
|
||||
BondOpts map[string]string `yaml:"bond_opts,omitempty"`
|
||||
PostUp []string `yaml:"post_up,omitempty"`
|
||||
PreUp []string `yaml:"pre_up,omitempty"`
|
||||
Vlans string `yaml:"vlans,omitempty"`
|
||||
}
|
||||
|
||||
type DnsConfig struct {
|
||||
Nameservers []string `yaml:"nameservers,flow,omitempty"`
|
||||
Search []string `yaml:"search,flow,omitempty"`
|
||||
}
|
||||
|
||||
type SshConfig struct {
|
||||
Keys map[string]string `yaml:"keys,omitempty"`
|
||||
}
|
||||
@ -192,7 +224,7 @@ type CloudInit struct {
|
||||
type Defaults struct {
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
Docker DockerConfig `yaml:"docker,omitempty"`
|
||||
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
||||
Network NetworkConfig `yaml:"network,omitempty"`
|
||||
}
|
||||
|
||||
func (r Repositories) ToArray() []string {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// +build linux
|
||||
package dockerlaunch
|
||||
|
||||
package dfs
|
||||
|
||||
import (
|
||||
"os"
|
@ -1,4 +1,4 @@
|
||||
package dockerlaunch
|
||||
package dfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -13,9 +13,10 @@ import (
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/libnetwork/resolvconf"
|
||||
"github.com/rancher/docker-from-scratch/selinux"
|
||||
"github.com/rancher/docker-from-scratch/util"
|
||||
"github.com/rancher/netconf"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/netconf"
|
||||
"github.com/rancher/os/selinux"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -45,7 +46,7 @@ type Config struct {
|
||||
Fork bool
|
||||
PidOne bool
|
||||
CommandName string
|
||||
DnsConfig netconf.DnsConfig
|
||||
DnsConfig config.DnsConfig
|
||||
BridgeName string
|
||||
BridgeAddress string
|
||||
BridgeMtu int
|
||||
@ -333,8 +334,8 @@ func createGroup() error {
|
||||
return tryCreateFile("/etc/group", "root:x:0:\n")
|
||||
}
|
||||
|
||||
func setupNetworking(config *Config) error {
|
||||
if config == nil {
|
||||
func setupNetworking(cfg *Config) error {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -351,19 +352,19 @@ ff02::2 ip6-allrouters
|
||||
|
||||
127.0.1.1 `+hostname)
|
||||
|
||||
if len(config.DnsConfig.Nameservers) != 0 {
|
||||
if _, err := resolvconf.Build("/etc/resolv.conf", config.DnsConfig.Nameservers, config.DnsConfig.Search, nil); err != nil {
|
||||
if len(cfg.DnsConfig.Nameservers) != 0 {
|
||||
if _, err := resolvconf.Build("/etc/resolv.conf", cfg.DnsConfig.Nameservers, cfg.DnsConfig.Search, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if config.BridgeName != "" && config.BridgeName != "none" {
|
||||
log.Debugf("Creating bridge %s (%s)", config.BridgeName, config.BridgeAddress)
|
||||
if err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{
|
||||
Interfaces: map[string]netconf.InterfaceConfig{
|
||||
config.BridgeName: {
|
||||
Address: config.BridgeAddress,
|
||||
MTU: config.BridgeMtu,
|
||||
if cfg.BridgeName != "" && cfg.BridgeName != "none" {
|
||||
log.Debugf("Creating bridge %s (%s)", cfg.BridgeName, cfg.BridgeAddress)
|
||||
if err := netconf.ApplyNetworkConfigs(&config.NetworkConfig{
|
||||
Interfaces: map[string]config.InterfaceConfig{
|
||||
cfg.BridgeName: {
|
||||
Address: cfg.BridgeAddress,
|
||||
MTU: cfg.BridgeMtu,
|
||||
Bridge: "true",
|
||||
},
|
||||
},
|
||||
@ -375,23 +376,37 @@ ff02::2 ip6-allrouters
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetValue(index int, args []string) string {
|
||||
val := args[index]
|
||||
parts := strings.SplitN(val, "=", 2)
|
||||
if len(parts) == 1 {
|
||||
if len(args) > index+1 {
|
||||
return args[index+1]
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
return parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
func ParseConfig(config *Config, args ...string) []string {
|
||||
for i, arg := range args {
|
||||
if strings.HasPrefix(arg, "--bip") {
|
||||
config.BridgeAddress = util.GetValue(i, args)
|
||||
config.BridgeAddress = GetValue(i, args)
|
||||
} else if strings.HasPrefix(arg, "--fixed-cidr") {
|
||||
config.BridgeAddress = util.GetValue(i, args)
|
||||
config.BridgeAddress = GetValue(i, args)
|
||||
} else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") {
|
||||
config.BridgeName = util.GetValue(i, args)
|
||||
config.BridgeName = GetValue(i, args)
|
||||
} else if strings.HasPrefix(arg, "--config-file") {
|
||||
config.DaemonConfig = util.GetValue(i, args)
|
||||
config.DaemonConfig = GetValue(i, args)
|
||||
} else if strings.HasPrefix(arg, "--mtu") {
|
||||
mtu, err := strconv.Atoi(util.GetValue(i, args))
|
||||
mtu, err := strconv.Atoi(GetValue(i, args))
|
||||
if err != nil {
|
||||
config.BridgeMtu = mtu
|
||||
}
|
||||
} else if strings.HasPrefix(arg, "-g") || strings.HasPrefix(arg, "--graph") {
|
||||
config.GraphDirectory = util.GetValue(i, args)
|
||||
config.GraphDirectory = GetValue(i, args)
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +469,7 @@ func touchSockets(args ...string) error {
|
||||
|
||||
for i, arg := range args {
|
||||
if strings.HasPrefix(arg, "-H") {
|
||||
val := util.GetValue(i, args)
|
||||
val := GetValue(i, args)
|
||||
if strings.HasPrefix(val, "unix://") {
|
||||
val = val[len("unix://"):]
|
||||
log.Debugf("Creating temp file at %s", val)
|
@ -4,9 +4,9 @@ import (
|
||||
"syscall"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/docker-from-scratch"
|
||||
"github.com/rancher/os/compose"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/dfs"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func startDocker(cfg *config.CloudConfig) (chan interface{}, error) {
|
||||
launchConfig.LogFile = ""
|
||||
launchConfig.NoLog = true
|
||||
|
||||
cmd, err := dockerlaunch.LaunchDocker(launchConfig, config.SYSTEM_DOCKER_BIN, args...)
|
||||
cmd, err := dfs.LaunchDocker(launchConfig, config.SYSTEM_DOCKER_BIN, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
16
init/init.go
16
init/init.go
@ -12,8 +12,8 @@ import (
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/rancher/docker-from-scratch"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/dfs"
|
||||
"github.com/rancher/os/util"
|
||||
"github.com/rancher/os/util/network"
|
||||
)
|
||||
@ -27,7 +27,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
mountConfig = dockerlaunch.Config{
|
||||
mountConfig = dfs.Config{
|
||||
CgroupHierarchy: map[string]string{
|
||||
"cpu": "cpu",
|
||||
"cpuacct": "cpu",
|
||||
@ -162,10 +162,10 @@ func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error)
|
||||
return mountOem(cfg)
|
||||
}
|
||||
|
||||
func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dockerlaunch.Config, []string) {
|
||||
var launchConfig dockerlaunch.Config
|
||||
func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dfs.Config, []string) {
|
||||
var launchConfig dfs.Config
|
||||
|
||||
args := dockerlaunch.ParseConfig(&launchConfig, dockerCfg.FullArgs()...)
|
||||
args := dfs.ParseConfig(&launchConfig, dockerCfg.FullArgs()...)
|
||||
|
||||
launchConfig.DnsConfig.Nameservers = cfg.Rancher.Defaults.Network.Dns.Nameservers
|
||||
launchConfig.DnsConfig.Search = cfg.Rancher.Defaults.Network.Dns.Search
|
||||
@ -220,7 +220,7 @@ func RunInit() error {
|
||||
boot2DockerEnvironment := false
|
||||
initFuncs := []config.CfgFunc{
|
||||
func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return c, dockerlaunch.PrepareFs(&mountConfig)
|
||||
return c, dfs.PrepareFs(&mountConfig)
|
||||
},
|
||||
mountOem,
|
||||
func(_ *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
@ -280,7 +280,7 @@ func RunInit() error {
|
||||
},
|
||||
loadModules,
|
||||
func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return c, dockerlaunch.PrepareFs(&mountConfig)
|
||||
return c, dfs.PrepareFs(&mountConfig)
|
||||
},
|
||||
func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
network.SetProxyEnvironmentVariables(c)
|
||||
@ -300,7 +300,7 @@ func RunInit() error {
|
||||
launchConfig.Fork = !cfg.Rancher.SystemDocker.Exec
|
||||
|
||||
log.Info("Launching System Docker")
|
||||
_, err = dockerlaunch.LaunchDocker(launchConfig, config.SYSTEM_DOCKER_BIN, args...)
|
||||
_, err = dfs.LaunchDocker(launchConfig, config.SYSTEM_DOCKER_BIN, args...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/rancher/docker-from-scratch"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/dfs"
|
||||
)
|
||||
|
||||
func cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir string) (bool, error) {
|
||||
@ -21,7 +21,7 @@ func cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir string) (bool, error)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if err := dockerlaunch.CreateSymlink(usrVer, path.Join(rootfs, "usr")); err != nil {
|
||||
if err := dfs.CreateSymlink(usrVer, path.Join(rootfs, "usr")); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
|
4
main.go
4
main.go
@ -6,7 +6,6 @@ import (
|
||||
"github.com/docker/docker/docker"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/rancher/cniglue"
|
||||
"github.com/rancher/docker-from-scratch"
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/cmd/cloudinitsave"
|
||||
"github.com/rancher/os/cmd/console"
|
||||
@ -20,6 +19,7 @@ import (
|
||||
"github.com/rancher/os/cmd/systemdocker"
|
||||
"github.com/rancher/os/cmd/userdocker"
|
||||
"github.com/rancher/os/cmd/wait"
|
||||
"github.com/rancher/os/dfs"
|
||||
osInit "github.com/rancher/os/init"
|
||||
)
|
||||
|
||||
@ -30,7 +30,7 @@ var entrypoints = map[string]func(){
|
||||
"console.sh": console.Main,
|
||||
"docker": docker.Main,
|
||||
"docker-init": dockerinit.Main,
|
||||
"dockerlaunch": dockerlaunch.Main,
|
||||
"dockerlaunch": dfs.Main,
|
||||
"halt": power.Halt,
|
||||
"init": osInit.MainInit,
|
||||
"netconf": network.Main,
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/flynn/go-shlex"
|
||||
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/ryanuber/go-glob"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
@ -26,7 +27,7 @@ var (
|
||||
defaultDhcpArgs = []string{"dhcpcd", "-MA4"}
|
||||
)
|
||||
|
||||
func createInterfaces(netCfg *NetworkConfig) {
|
||||
func createInterfaces(netCfg *config.NetworkConfig) {
|
||||
configured := map[string]bool{}
|
||||
|
||||
for name, iface := range netCfg.Interfaces {
|
||||
@ -64,7 +65,7 @@ func createInterfaces(netCfg *NetworkConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
func createSlaveInterfaces(netCfg *NetworkConfig) {
|
||||
func createSlaveInterfaces(netCfg *config.NetworkConfig) {
|
||||
links, err := netlink.LinkList()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to list links: %v", err)
|
||||
@ -91,9 +92,9 @@ func createSlaveInterfaces(netCfg *NetworkConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
func findMatch(link netlink.Link, netCfg *NetworkConfig) (InterfaceConfig, bool) {
|
||||
func findMatch(link netlink.Link, netCfg *config.NetworkConfig) (config.InterfaceConfig, bool) {
|
||||
linkName := link.Attrs().Name
|
||||
var match InterfaceConfig
|
||||
var match config.InterfaceConfig
|
||||
exactMatch := false
|
||||
found := false
|
||||
|
||||
@ -135,25 +136,25 @@ func findMatch(link netlink.Link, netCfg *NetworkConfig) (InterfaceConfig, bool)
|
||||
return match, exactMatch || found
|
||||
}
|
||||
|
||||
func populateDefault(netCfg *NetworkConfig) {
|
||||
func populateDefault(netCfg *config.NetworkConfig) {
|
||||
if netCfg.Interfaces == nil {
|
||||
netCfg.Interfaces = map[string]InterfaceConfig{}
|
||||
netCfg.Interfaces = map[string]config.InterfaceConfig{}
|
||||
}
|
||||
|
||||
if len(netCfg.Interfaces) == 0 {
|
||||
netCfg.Interfaces["eth*"] = InterfaceConfig{
|
||||
netCfg.Interfaces["eth*"] = config.InterfaceConfig{
|
||||
DHCP: true,
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := netCfg.Interfaces["lo"]; !ok {
|
||||
netCfg.Interfaces["lo"] = InterfaceConfig{
|
||||
netCfg.Interfaces["lo"] = config.InterfaceConfig{
|
||||
Address: "127.0.0.1/8",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ApplyNetworkConfigs(netCfg *NetworkConfig) error {
|
||||
func ApplyNetworkConfigs(netCfg *config.NetworkConfig) error {
|
||||
populateDefault(netCfg)
|
||||
|
||||
log.Debugf("Config: %#v", netCfg)
|
||||
@ -182,7 +183,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func RunDhcp(netCfg *NetworkConfig, setHostname, setDns bool) error {
|
||||
func RunDhcp(netCfg *config.NetworkConfig, setHostname, setDns bool) error {
|
||||
populateDefault(netCfg)
|
||||
|
||||
links, err := netlink.LinkList()
|
||||
@ -211,7 +212,7 @@ func RunDhcp(netCfg *NetworkConfig, setHostname, setDns bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, setDns bool) {
|
||||
func runDhcp(netCfg *config.NetworkConfig, iface string, argstr string, setHostname, setDns bool) {
|
||||
log.Infof("Running DHCP on %s", iface)
|
||||
args := []string{}
|
||||
if argstr != "" {
|
||||
@ -242,7 +243,7 @@ func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, se
|
||||
}
|
||||
}
|
||||
|
||||
func linkUp(link netlink.Link, netConf InterfaceConfig) error {
|
||||
func linkUp(link netlink.Link, netConf config.InterfaceConfig) error {
|
||||
if err := netlink.LinkSetUp(link); err != nil {
|
||||
log.Errorf("failed to setup link: %v", err)
|
||||
return err
|
||||
@ -251,7 +252,7 @@ func linkUp(link netlink.Link, netConf InterfaceConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyAddress(address string, link netlink.Link, netConf InterfaceConfig) error {
|
||||
func applyAddress(address string, link netlink.Link, netConf config.InterfaceConfig) error {
|
||||
addr, err := netlink.ParseAddr(address)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -293,7 +294,7 @@ func setGateway(gateway string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyInterfaceConfig(link netlink.Link, netConf InterfaceConfig) error {
|
||||
func applyInterfaceConfig(link netlink.Link, netConf config.InterfaceConfig) error {
|
||||
if netConf.Bond != "" {
|
||||
if err := netlink.LinkSetDown(link); err != nil {
|
||||
return err
|
||||
@ -388,7 +389,7 @@ func runCmds(cmds []string, iface string) {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Errorf("Failed to run command [%s]: %v", cmd, err)
|
||||
log.Errorf("Failed to run command [%v]: %v", cmd, err)
|
||||
continue
|
||||
}
|
||||
}
|
@ -9,3 +9,8 @@ func InitializeSelinux() (int, error) {
|
||||
ret, err := C.selinux_init_load_policy(&enforce)
|
||||
return int(ret), err
|
||||
}
|
||||
|
||||
func SetFileContext(path string, context string) (int, error) {
|
||||
ret, err := C.setfilecon(C.CString(path), C.CString(context))
|
||||
return int(ret), err
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ github.com/packethost/packngo 7b3a781a3c8c45b0e55390fa3c4d24981402b99f https://g
|
||||
github.com/pkg/errors d62207b3dc916c342cd6a7180fa861d898cf42ee
|
||||
github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
github.com/rancher/cniglue b56bd68e5df113ad3fcc59c58034c22afaede877
|
||||
github.com/rancher/docker-from-scratch 084910d99b12408467a559f338e5a27bf4a1aed3
|
||||
github.com/rancher/netconf ddd7e35a6aacd7e80991920774083dd4408ec018
|
||||
github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43
|
||||
github.com/ryanuber/go-glob 0067a9abd927e50aed5190662702f81231413ae0
|
||||
github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1
|
||||
|
3
vendor/github.com/rancher/docker-from-scratch/.dockerignore
generated
vendored
3
vendor/github.com/rancher/docker-from-scratch/.dockerignore
generated
vendored
@ -1,3 +0,0 @@
|
||||
base-image
|
||||
assets
|
||||
.vendor
|
6
vendor/github.com/rancher/docker-from-scratch/.drone.yml
generated
vendored
6
vendor/github.com/rancher/docker-from-scratch/.drone.yml
generated
vendored
@ -1,6 +0,0 @@
|
||||
build:
|
||||
image: rancher/dapper:1.10.3
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
commands:
|
||||
- dapper ./scripts/ci
|
8
vendor/github.com/rancher/docker-from-scratch/.gitignore
generated
vendored
8
vendor/github.com/rancher/docker-from-scratch/.gitignore
generated
vendored
@ -1,8 +0,0 @@
|
||||
/dist
|
||||
/build
|
||||
/assets
|
||||
/base-image/assets/
|
||||
/base-image/build/
|
||||
/base-image/cache/
|
||||
/base-image/dist/
|
||||
/.vendor
|
1
vendor/github.com/rancher/docker-from-scratch/.wrap-docker-args
generated
vendored
1
vendor/github.com/rancher/docker-from-scratch/.wrap-docker-args
generated
vendored
@ -1 +0,0 @@
|
||||
--privileged
|
8
vendor/github.com/rancher/docker-from-scratch/Dockerfile
generated
vendored
8
vendor/github.com/rancher/docker-from-scratch/Dockerfile
generated
vendored
@ -1,8 +0,0 @@
|
||||
FROM scratch
|
||||
ADD build/base-files.tar.gz /
|
||||
COPY build/ca-certificates.crt /usr/etc/ssl/certs/
|
||||
COPY build/dockerlaunch /usr/bin/
|
||||
COPY build/docker* /usr/bin/
|
||||
VOLUME /var/lib/docker
|
||||
ENTRYPOINT ["/usr/bin/dockerlaunch", "/usr/bin/docker"]
|
||||
CMD ["daemon", "-s", "overlay"]
|
41
vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper
generated
vendored
41
vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper
generated
vendored
@ -1,41 +0,0 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install locales sudo vim less curl wget git rsync build-essential isolinux xorriso gccgo \
|
||||
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates pkg-config tox
|
||||
|
||||
COPY ./scripts/install-libs.sh /tmp/
|
||||
RUN /tmp/install-libs.sh
|
||||
|
||||
RUN wget -O - https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz | tar -xz -C /usr/local
|
||||
RUN wget -O /usr/local/bin/docker -L https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 && \
|
||||
chmod +x /usr/local/bin/docker
|
||||
|
||||
ENV PATH /usr/local/go/bin:$PATH
|
||||
RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
|
||||
ENV GOPATH /go
|
||||
ENV PATH /go/bin:$PATH
|
||||
|
||||
ENV DAPPER_SOURCE /go/src/github.com/rancher/docker-from-scratch
|
||||
ENV DAPPER_OUTPUT ""
|
||||
ENV DAPPER_DOCKER_SOCKET true
|
||||
ENV DAPPER_ENV NO_TEST ARCH
|
||||
|
||||
RUN mkdir -p ${DAPPER_SOURCE}/assets && ln -s ${DAPPER_SOURCE} /source
|
||||
|
||||
WORKDIR ${DAPPER_SOURCE}/assets
|
||||
|
||||
RUN wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_amd64.tar.gz && \
|
||||
wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_arm.tar.gz && \
|
||||
wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_arm64.tar.gz
|
||||
|
||||
ENV DOCKER_VERSION=1.11.2 DOCKER_PATCH_VERSION=v1.11.2-ros1
|
||||
ENV VERSION=v${DOCKER_VERSION}-2
|
||||
|
||||
RUN wget -O docker-${DOCKER_VERSION}_amd64.tgz -L https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz && \
|
||||
wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm.tgz && \
|
||||
wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm64.tgz
|
||||
|
||||
WORKDIR ${DAPPER_SOURCE}
|
||||
|
||||
CMD ./scripts/ci
|
178
vendor/github.com/rancher/docker-from-scratch/LICENSE
generated
vendored
178
vendor/github.com/rancher/docker-from-scratch/LICENSE
generated
vendored
@ -1,178 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
105
vendor/github.com/rancher/docker-from-scratch/README.md
generated
vendored
105
vendor/github.com/rancher/docker-from-scratch/README.md
generated
vendored
@ -1,105 +0,0 @@
|
||||
# Docker `FROM scratch`
|
||||
|
||||
Docker-in-Docker image based off of the empty image `scratch`. Only the bare minimum required files are included to make Docker run. This image weighs in around 25MB expanded.
|
||||
|
||||
## Running
|
||||
|
||||
### Overlay
|
||||
|
||||
```bash
|
||||
# Daemon
|
||||
docker run --name daemon --privileged -d rancher/docker
|
||||
|
||||
# Client
|
||||
docker exec -it daemon docker ps
|
||||
```
|
||||
|
||||
### Aufs
|
||||
|
||||
```bash
|
||||
# Daemon
|
||||
docker run --name daemon --privileged -d rancher/docker daemon -s aufs
|
||||
|
||||
# Client
|
||||
docker exec -it daemon docker ps
|
||||
```
|
||||
|
||||
## Embed in Custom Image
|
||||
|
||||
Since docker-from-scratch doesn't assume a base Linux distro it can be easily copied into an other image to add Docker-in-Docker capabilities
|
||||
|
||||
```bash
|
||||
docker export $(docker create rancher/docker) > files.tar
|
||||
|
||||
cat > Dockerfile << EOF
|
||||
|
||||
FROM ubuntu
|
||||
ADD files.tar /
|
||||
ENTRYPOINT ["/usr/bin/dockerlaunch", "/usr/bin/docker"]
|
||||
VOLUME /var/lib/docker
|
||||
CMD ["daemon", "-s", "overlay"]
|
||||
|
||||
EOF
|
||||
|
||||
docker build -t custom-dind .
|
||||
```
|
||||
|
||||
## Graph Driver Compatibility
|
||||
|
||||
This image is really designed to run with overlay. Aufs is known to work but other graph drivers may not work properly or be missing userspace programs needed.
|
||||
|
||||
|
||||
## Seriously, Why?
|
||||
|
||||
This code and the supporting files were extracted out of RancherOS into a separate library and are still used by RancherOS. RancherOS runs Docker as the first process but before we can exec Docker we need to setup a minimal environment for Docker in which to run. Since RancherOS is executed by the kernel there is absolutely nothing setup in the system. At Rancher we wrote a small amount of code to setup all the required mounts and directories to launch Docker.
|
||||
|
||||
We moved this code out into a separate project for two reasons. First was simply that we wanted to clean up and modularize the RancherOS code base. Second is that we wanted to demonstrate clearly what exactly Docker requires from the Linux user space. For the most part Docker requires the standard mounts (`/proc`, `/sys`, `/run`, `/var/run`, etc) and the cgroup mounts in `/sys/fs/cgroup` plus the following programs/files:
|
||||
|
||||
|
||||
```
|
||||
/etc/ssl/certs/ca-certificates.crt
|
||||
/usr/bin/modprobe
|
||||
/usr/bin/iptables
|
||||
/usr/bin/ssh
|
||||
/usr/bin/xz
|
||||
/usr/bin/git
|
||||
/usr/bin/ps
|
||||
/usr/libexec/git-core/git-clone
|
||||
/usr/libexec/git-core/git-submodule
|
||||
/usr/libexec/git-core/git-checkout
|
||||
```
|
||||
|
||||
This list can be reduced to a bare minimum if you ignore certain features of Docker. A full description of why each program is needed is below.
|
||||
|
||||
File | Description | Can it be ignored
|
||||
-----|-------------|------------------
|
||||
`/etc/ssl/certs/ca-certificates.crt` | Used as the CA roots to validate SSL connections | No
|
||||
`/usr/bin/modprobe` | Used to ensure that bridge, nf_nat, br_netfilter, aufs, or overlay modules are loaded. Additionally iptables loads kernel modules based on the configuration of the rules | Yes, just load the modules from the host that you will need.
|
||||
`/usr/bin/iptables` | Docker uses IPtables to setup networking | Yes, add `--iptables=false` to the `docker -d` command. Networking will have to be manually configured in this situation
|
||||
`/usr/bin/ssh`| Used by git to clone repos over SSH | Yes, don't use git based Docker builds
|
||||
`/usr/bin/xz` | Used to extract *legacy* Docker images that were compressed with xz | Yes, only use newer images. Most popular images are not based on xz
|
||||
`/usr/bin/git` | Used to do Docker builds from a git URL | Yes, don't use git based Docker builds
|
||||
`/usr/bin/ps` | `docker ps` uses the host `ps` to get information about the running process in a container | No
|
||||
`/usr/libexec/git-core/git-clone`| Used by git | Yes, don't use git based Docker builds
|
||||
`/usr/libexec/git-core/git-submodule`| Used by git | Yes, don't use git based Docker builds
|
||||
`/usr/libexec/git-core/git-checkout`| Used by git | Yes, don't use git based Docker builds
|
||||
|
||||
## Custom Bridge Name
|
||||
|
||||
If you want to run with a custom bridge name you must pass both `--bip` and `-b` as arguments. Normally this would be an error for Docker but in this situation the docker-from-scratch container will create the bridge device with the IP address specified and then old pass `-b` to Docker.
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
## Zombies
|
||||
|
||||
If you are running containers with `--pid=host` you can get zombies. When you launch docker-from-scratch just add `-e DOCKER_LAUNCH_REAP=true` as a parameter to the `docker run` command to fix this.
|
||||
|
||||
## Weird module loading errors
|
||||
|
||||
For various reasons Docker or iptables may try to load a kernel module. You can either manually load all the needed modules from the host or you can bind mount in the kernel modules by adding `-v /lib/modules/$(uname -r)/lib/modules/$(uname -r)` to your `docker run` command
|
||||
|
||||
## Debug Logging
|
||||
|
||||
To enable debug logging on the startup of docker-from-scrach just add `-e DOCKER_LAUNCH_DEBUG=true` to the `docker run` command. For example:
|
||||
|
||||
docker run --name daemon --privileged -d -e DOCKER_LAUNCH_DEBUG=true rancher/docker
|
7
vendor/github.com/rancher/docker-from-scratch/build.sh
generated
vendored
7
vendor/github.com/rancher/docker-from-scratch/build.sh
generated
vendored
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname $0)
|
||||
rm -rf ./build
|
||||
|
||||
export NO_TEST=true
|
||||
dapper ./scripts/ci
|
10
vendor/github.com/rancher/docker-from-scratch/selinux/selinux_linux.go
generated
vendored
10
vendor/github.com/rancher/docker-from-scratch/selinux/selinux_linux.go
generated
vendored
@ -1,10 +0,0 @@
|
||||
package selinux
|
||||
|
||||
// #cgo pkg-config: libselinux
|
||||
// #include <selinux/selinux.h>
|
||||
import "C"
|
||||
|
||||
func SetFileContext(path string, context string) (int, error) {
|
||||
ret, err := C.setfilecon(C.CString(path), C.CString(context))
|
||||
return int(ret), err
|
||||
}
|
37
vendor/github.com/rancher/docker-from-scratch/trash.yml
generated
vendored
37
vendor/github.com/rancher/docker-from-scratch/trash.yml
generated
vendored
@ -1,37 +0,0 @@
|
||||
package: github.com/rancher/docker-from-scratch
|
||||
|
||||
import:
|
||||
- package: github.com/Sirupsen/logrus
|
||||
version: 3cb248e9df77413d58a6330dde84236d04c197d5
|
||||
|
||||
- package: github.com/docker/docker
|
||||
version: v1.9.1
|
||||
subpackages:
|
||||
- pkg/ioutils
|
||||
- pkg/mount
|
||||
|
||||
- package: github.com/docker/libnetwork
|
||||
version: 077b0764e4926509c9e6213ae7b110de48494810
|
||||
subpackages:
|
||||
- resolvconf
|
||||
|
||||
- package: github.com/j-keck/arping
|
||||
version: 4f4d2c8983a18e2c9c63a3f339bc9a998c4557bc
|
||||
|
||||
- package: github.com/rancher/netconf
|
||||
version: bf95fd720be9de4f7aa3a4a529b70f2865dd0fc7
|
||||
|
||||
- package: github.com/ryanuber/go-glob
|
||||
version: 0067a9abd927e50aed5190662702f81231413ae0
|
||||
|
||||
- package: github.com/stretchr/testify
|
||||
version: a1f97990ddc16022ec7610326dd9bce31332c116
|
||||
subpackages:
|
||||
- assert
|
||||
- require
|
||||
|
||||
- package: github.com/vishvananda/netlink
|
||||
version: edcd99c0881a4de0fdb3818af6b24f4ee6948464
|
||||
|
||||
- package: github.com/flynn/go-shlex
|
||||
version: 3f9db97f856818214da2e1057f8ad84803971cff
|
19
vendor/github.com/rancher/docker-from-scratch/util/util.go
generated
vendored
19
vendor/github.com/rancher/docker-from-scratch/util/util.go
generated
vendored
@ -1,19 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetValue(index int, args []string) string {
|
||||
val := args[index]
|
||||
parts := strings.SplitN(val, "=", 2)
|
||||
if len(parts) == 1 {
|
||||
if len(args) > index+1 {
|
||||
return args[index+1]
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
return parts[1]
|
||||
}
|
||||
}
|
41
vendor/github.com/rancher/docker-from-scratch/util/util_linux.go
generated
vendored
41
vendor/github.com/rancher/docker-from-scratch/util/util_linux.go
generated
vendored
@ -1,41 +0,0 @@
|
||||
// +build linux
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
)
|
||||
|
||||
func mountProc() error {
|
||||
if _, err := os.Stat("/proc/self/mountinfo"); os.IsNotExist(err) {
|
||||
if _, err := os.Stat("/proc"); os.IsNotExist(err) {
|
||||
if err = os.Mkdir("/proc", 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := syscall.Mount("none", "/proc", "proc", 0, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Mount(device, directory, fsType, options string) error {
|
||||
if err := mountProc(); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := os.Stat(directory); os.IsNotExist(err) {
|
||||
err = os.MkdirAll(directory, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return mount.Mount(device, directory, fsType, options)
|
||||
}
|
1
vendor/github.com/rancher/netconf/.gitignore
generated
vendored
1
vendor/github.com/rancher/netconf/.gitignore
generated
vendored
@ -1 +0,0 @@
|
||||
/netconf
|
178
vendor/github.com/rancher/netconf/LICENSE
generated
vendored
178
vendor/github.com/rancher/netconf/LICENSE
generated
vendored
@ -1,178 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
3
vendor/github.com/rancher/netconf/README.md
generated
vendored
3
vendor/github.com/rancher/netconf/README.md
generated
vendored
@ -1,3 +0,0 @@
|
||||
# RancherOS Netconf
|
||||
|
||||
Simple wrapper around various netlink calls to configure networking
|
34
vendor/github.com/rancher/netconf/types.go
generated
vendored
34
vendor/github.com/rancher/netconf/types.go
generated
vendored
@ -1,34 +0,0 @@
|
||||
package netconf
|
||||
|
||||
type NetworkConfig struct {
|
||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||
Dns DnsConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||
HttpProxy string `yaml:"http_proxy,omitempty"`
|
||||
HttpsProxy string `yaml:"https_proxy,omitempty"`
|
||||
NoProxy string `yaml:"no_proxy,omitempty"`
|
||||
}
|
||||
|
||||
type InterfaceConfig struct {
|
||||
Match string `yaml:"match,omitempty"`
|
||||
DHCP bool `yaml:"dhcp,omitempty"`
|
||||
DHCPArgs string `yaml:"dhcp_args,omitempty"`
|
||||
Address string `yaml:"address,omitempty"`
|
||||
Addresses []string `yaml:"addresses,omitempty"`
|
||||
IPV4LL bool `yaml:"ipv4ll,omitempty"`
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
GatewayIpv6 string `yaml:"gateway_ipv6,omitempty"`
|
||||
MTU int `yaml:"mtu,omitempty"`
|
||||
Bridge string `yaml:"bridge,omitempty"`
|
||||
Bond string `yaml:"bond,omitempty"`
|
||||
BondOpts map[string]string `yaml:"bond_opts,omitempty"`
|
||||
PostUp []string `yaml:"post_up,omitempty"`
|
||||
PreUp []string `yaml:"pre_up,omitempty"`
|
||||
Vlans string `yaml:"vlans,omitempty"`
|
||||
}
|
||||
|
||||
type DnsConfig struct {
|
||||
Nameservers []string `yaml:"nameservers,flow,omitempty"`
|
||||
Search []string `yaml:"search,flow,omitempty"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user