mirror of
https://github.com/rancher/os.git
synced 2025-09-02 15:24:32 +00:00
Update vendor.conf and vendor package to support dind
This commit is contained in:
36
vendor/github.com/docker/libcompose/docker/container.go
generated
vendored
36
vendor/github.com/docker/libcompose/docker/container.go
generated
vendored
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/docker/libcompose/logger"
|
||||
"github.com/docker/libcompose/project"
|
||||
"github.com/docker/libcompose/project/events"
|
||||
"github.com/docker/engine-api/types/network"
|
||||
util "github.com/docker/libcompose/utils"
|
||||
)
|
||||
|
||||
@@ -506,9 +507,42 @@ func (c *Container) createContainer(ctx context.Context, imageName, oldContainer
|
||||
configWrapper.HostConfig.Binds = util.Merge(configWrapper.HostConfig.Binds, volumeBinds(configWrapper.Config.Volumes, &info))
|
||||
}
|
||||
|
||||
networkConfig := configWrapper.NetworkingConfig
|
||||
if configWrapper.HostConfig.NetworkMode != "" && configWrapper.HostConfig.NetworkMode.IsUserDefined() {
|
||||
if networkConfig == nil {
|
||||
// check user docker label, assign the user define ipv4 address
|
||||
if _, ok := configWrapper.Config.Labels["io.rancher.user_docker.fix_ip"]; ok {
|
||||
networkConfig = &network.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*network.EndpointSettings{
|
||||
string(configWrapper.HostConfig.NetworkMode): {
|
||||
IPAddress: configWrapper.Config.Labels["io.rancher.user_docker.fix_ip"],
|
||||
IPAMConfig: &network.EndpointIPAMConfig{
|
||||
IPv4Address: configWrapper.Config.Labels["io.rancher.user_docker.fix_ip"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
networkConfig = &network.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*network.EndpointSettings{
|
||||
string(configWrapper.HostConfig.NetworkMode): {},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
for key, value := range networkConfig.EndpointsConfig {
|
||||
conf := value
|
||||
if value.Aliases == nil {
|
||||
value.Aliases = []string{}
|
||||
}
|
||||
value.Aliases = append(value.Aliases, c.serviceName)
|
||||
networkConfig.EndpointsConfig[key] = conf
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("Creating container %s %#v", c.name, configWrapper)
|
||||
|
||||
container, err := c.client.ContainerCreate(ctx, configWrapper.Config, configWrapper.HostConfig, configWrapper.NetworkingConfig, c.name)
|
||||
container, err := c.client.ContainerCreate(ctx, configWrapper.Config, configWrapper.HostConfig, networkConfig, c.name)
|
||||
if err != nil {
|
||||
logrus.Debugf("Failed to create container %s: %v", c.name, err)
|
||||
return nil, err
|
||||
|
71
vendor/github.com/docker/libcompose/docker/service.go
generated
vendored
71
vendor/github.com/docker/libcompose/docker/service.go
generated
vendored
@@ -5,6 +5,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/engine-api/types/network"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
@@ -257,6 +258,10 @@ func (s *Service) Run(ctx context.Context, commandParts []string) (int, error) {
|
||||
|
||||
c := NewOneOffContainer(client, containerName, containerNumber, s)
|
||||
|
||||
if err := s.connectContainerToNetworks(ctx, c, true); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return c.Run(ctx, imageName, &config.ServiceConfig{Command: commandParts, Tty: true, StdinOpen: true})
|
||||
}
|
||||
|
||||
@@ -308,6 +313,10 @@ func (s *Service) up(ctx context.Context, imageName string, create bool, options
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.connectContainerToNetworks(ctx, c, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if options.Log {
|
||||
go c.Log(ctx, true)
|
||||
}
|
||||
@@ -510,3 +519,65 @@ func (s *Service) specificiesHostPort() bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Service) connectContainerToNetworks(ctx context.Context, c *Container, oneOff bool) error {
|
||||
existingContainer, err := c.findExisting(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
connectedNetworks := existingContainer.NetworkSettings.Networks
|
||||
|
||||
if _, ok := s.serviceConfig.Labels["io.rancher.user_docker.net"]; ok {
|
||||
for networkName, connectedNetwork := range connectedNetworks {
|
||||
aliasPresent := false
|
||||
for _, alias := range connectedNetwork.Aliases {
|
||||
ID, _ := c.ID()
|
||||
ID = ID[:12]
|
||||
if alias == ID {
|
||||
aliasPresent = true
|
||||
}
|
||||
}
|
||||
if aliasPresent {
|
||||
continue
|
||||
}
|
||||
if err := s.NetworkDisconnect(ctx, c, networkName, oneOff); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _, fipExist := s.serviceConfig.Labels["io.rancher.user_docker.fix_ip"]; fipExist {
|
||||
if err := s.NetworkConnect(ctx, c, s.serviceConfig.Labels["io.rancher.user_docker.net"], s.serviceConfig.Labels["io.rancher.user_docker.fix_ip"], oneOff); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NetworkConnect connects the container to the specified network
|
||||
// FIXME(vdemeester) will be refactor with Container refactoring
|
||||
func (s *Service) NetworkConnect(ctx context.Context, c *Container, net, ipv4 string, oneOff bool) error {
|
||||
containerID, err := c.ID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := s.context.ClientFactory.Create(s)
|
||||
return client.NetworkConnect(ctx, net, containerID, &network.EndpointSettings{
|
||||
IPAddress: ipv4,
|
||||
IPAMConfig: &network.EndpointIPAMConfig{
|
||||
IPv4Address: ipv4,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// NetworkDisconnect disconnects the container from the specified network
|
||||
func (s *Service) NetworkDisconnect(ctx context.Context, c *Container, net string, oneOff bool) error {
|
||||
containerID, err := c.ID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := s.context.ClientFactory.Create(s)
|
||||
return client.NetworkDisconnect(ctx, net, containerID, true)
|
||||
}
|
||||
|
Reference in New Issue
Block a user