2015-11-01 15:35:01 +00:00
|
|
|
package provider
|
2015-09-12 13:10:03 +00:00
|
|
|
|
2015-09-07 22:15:14 +00:00
|
|
|
import (
|
2015-09-15 20:32:09 +00:00
|
|
|
"errors"
|
2016-04-08 12:20:54 +00:00
|
|
|
"net/http"
|
2015-09-24 15:16:13 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"text/template"
|
|
|
|
"time"
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
2015-09-10 20:54:37 +00:00
|
|
|
"github.com/BurntSushi/ty/fun"
|
2015-09-24 12:32:37 +00:00
|
|
|
log "github.com/Sirupsen/logrus"
|
2015-09-15 20:32:09 +00:00
|
|
|
"github.com/cenkalti/backoff"
|
2016-03-31 16:57:08 +00:00
|
|
|
"github.com/containous/traefik/safe"
|
2016-02-24 15:43:39 +00:00
|
|
|
"github.com/containous/traefik/types"
|
2016-04-08 12:20:54 +00:00
|
|
|
"github.com/docker/engine-api/client"
|
|
|
|
dockertypes "github.com/docker/engine-api/types"
|
|
|
|
eventtypes "github.com/docker/engine-api/types/events"
|
|
|
|
"github.com/docker/engine-api/types/filters"
|
|
|
|
"github.com/docker/go-connections/sockets"
|
|
|
|
"github.com/vdemeester/docker-events"
|
2015-09-07 08:38:58 +00:00
|
|
|
)
|
2015-09-09 20:39:08 +00:00
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
// DockerAPIVersion is a constant holding the version of the Docker API traefik will use
|
|
|
|
const DockerAPIVersion string = "1.21"
|
|
|
|
|
2015-11-01 18:29:47 +00:00
|
|
|
// Docker holds configurations of the Docker provider.
|
2015-11-02 18:48:34 +00:00
|
|
|
type Docker struct {
|
2016-06-24 07:58:42 +00:00
|
|
|
BaseProvider `mapstructure:",squash"`
|
2016-07-14 09:32:15 +00:00
|
|
|
Endpoint string `description:"Docker server endpoint. Can be a tcp or a unix socket endpoint"`
|
|
|
|
Domain string `description:"Default domain used"`
|
2016-06-27 14:14:56 +00:00
|
|
|
TLS *ClientTLS `description:"Enable Docker TLS support"`
|
2016-07-14 09:32:15 +00:00
|
|
|
ExposedByDefault bool `description:"Expose containers by default"`
|
2015-11-20 15:05:06 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) createClient() (client.APIClient, error) {
|
|
|
|
var httpClient *http.Client
|
|
|
|
httpHeaders := map[string]string{
|
|
|
|
// FIXME(vdemeester) use version here O:)
|
|
|
|
"User-Agent": "Traefik",
|
|
|
|
}
|
|
|
|
if provider.TLS != nil {
|
2016-06-27 14:14:56 +00:00
|
|
|
config, err := provider.TLS.CreateTLSConfig()
|
2016-04-08 12:20:54 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
tr := &http.Transport{
|
|
|
|
TLSClientConfig: config,
|
|
|
|
}
|
|
|
|
proto, addr, _, err := client.ParseHost(provider.Endpoint)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
sockets.ConfigureTransport(tr, proto, addr)
|
|
|
|
|
|
|
|
httpClient = &http.Client{
|
|
|
|
Transport: tr,
|
|
|
|
}
|
2016-06-27 14:14:56 +00:00
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
}
|
|
|
|
return client.NewClient(provider.Endpoint, DockerAPIVersion, httpClient, httpHeaders)
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:29:47 +00:00
|
|
|
// Provide allows the provider to provide configurations to traefik
|
|
|
|
// using the given configuration channel.
|
2016-05-31 07:54:42 +00:00
|
|
|
func (provider *Docker) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints []types.Constraint) error {
|
2016-05-30 13:05:58 +00:00
|
|
|
provider.Constraints = append(provider.Constraints, constraints...)
|
2016-04-13 18:36:23 +00:00
|
|
|
// TODO register this routine in pool, and watch for stop channel
|
2016-03-31 16:57:08 +00:00
|
|
|
safe.Go(func() {
|
2016-02-25 17:30:13 +00:00
|
|
|
operation := func() error {
|
|
|
|
var err error
|
2015-11-01 18:29:47 +00:00
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
dockerClient, err := provider.createClient()
|
2016-02-25 17:30:13 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("Failed to create a client for docker, error: %s", err)
|
|
|
|
return err
|
|
|
|
}
|
2016-06-08 17:39:38 +00:00
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
version, err := dockerClient.ServerVersion(ctx)
|
2016-04-08 12:20:54 +00:00
|
|
|
log.Debugf("Docker connection established with docker %s (API %s)", version.Version, version.APIVersion)
|
2016-06-08 17:39:38 +00:00
|
|
|
containers, err := listContainers(ctx, dockerClient)
|
2016-02-25 17:30:13 +00:00
|
|
|
if err != nil {
|
2016-04-08 12:20:54 +00:00
|
|
|
log.Errorf("Failed to list containers for docker, error %s", err)
|
2016-02-25 17:30:13 +00:00
|
|
|
return err
|
|
|
|
}
|
2016-04-08 12:20:54 +00:00
|
|
|
configuration := provider.loadDockerConfig(containers)
|
2016-02-25 17:30:13 +00:00
|
|
|
configurationChan <- types.ConfigMessage{
|
|
|
|
ProviderName: "docker",
|
|
|
|
Configuration: configuration,
|
|
|
|
}
|
|
|
|
if provider.Watch {
|
2016-06-08 17:39:38 +00:00
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
2016-06-16 20:49:57 +00:00
|
|
|
pool.Go(func(stop chan bool) {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-stop:
|
|
|
|
cancel()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2016-04-08 12:20:54 +00:00
|
|
|
f := filters.NewArgs()
|
|
|
|
f.Add("type", "container")
|
|
|
|
options := dockertypes.EventsOptions{
|
|
|
|
Filters: f,
|
|
|
|
}
|
|
|
|
eventHandler := events.NewHandler(events.ByAction)
|
|
|
|
startStopHandle := func(m eventtypes.Message) {
|
|
|
|
log.Debugf("Docker event received %+v", m)
|
2016-06-08 17:39:38 +00:00
|
|
|
containers, err := listContainers(ctx, dockerClient)
|
2016-04-08 12:20:54 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("Failed to list containers for docker, error %s", err)
|
|
|
|
// Call cancel to get out of the monitor
|
|
|
|
cancel()
|
2016-06-08 17:39:38 +00:00
|
|
|
return
|
2015-11-01 18:29:47 +00:00
|
|
|
}
|
2016-04-08 12:20:54 +00:00
|
|
|
configuration := provider.loadDockerConfig(containers)
|
|
|
|
if configuration != nil {
|
|
|
|
configurationChan <- types.ConfigMessage{
|
|
|
|
ProviderName: "docker",
|
|
|
|
Configuration: configuration,
|
2015-09-10 20:54:37 +00:00
|
|
|
}
|
2015-09-10 07:06:37 +00:00
|
|
|
}
|
2015-09-09 20:39:08 +00:00
|
|
|
}
|
2016-04-08 12:20:54 +00:00
|
|
|
eventHandler.Handle("start", startStopHandle)
|
|
|
|
eventHandler.Handle("die", startStopHandle)
|
2016-04-13 18:36:23 +00:00
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
errChan := events.MonitorWithHandler(ctx, dockerClient, options, eventHandler)
|
|
|
|
if err := <-errChan; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-11-01 18:29:47 +00:00
|
|
|
}
|
2016-02-25 17:30:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
notify := func(err error, time time.Duration) {
|
|
|
|
log.Errorf("Docker connection error %+v, retrying in %s", err, time)
|
|
|
|
}
|
|
|
|
err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Cannot connect to docker server %+v", err)
|
|
|
|
}
|
2016-03-31 16:57:08 +00:00
|
|
|
})
|
2015-11-01 18:29:47 +00:00
|
|
|
|
2015-10-01 10:04:25 +00:00
|
|
|
return nil
|
2015-09-07 08:38:58 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) loadDockerConfig(containersInspected []dockertypes.ContainerJSON) *types.Configuration {
|
2015-10-08 19:21:51 +00:00
|
|
|
var DockerFuncMap = template.FuncMap{
|
2015-11-13 10:50:32 +00:00
|
|
|
"getBackend": provider.getBackend,
|
2016-06-01 05:11:17 +00:00
|
|
|
"getIPAddress": provider.getIPAddress,
|
2015-11-13 10:50:32 +00:00
|
|
|
"getPort": provider.getPort,
|
|
|
|
"getWeight": provider.getWeight,
|
|
|
|
"getDomain": provider.getDomain,
|
|
|
|
"getProtocol": provider.getProtocol,
|
|
|
|
"getPassHostHeader": provider.getPassHostHeader,
|
2016-06-06 20:30:23 +00:00
|
|
|
"getPriority": provider.getPriority,
|
2016-02-01 15:08:58 +00:00
|
|
|
"getEntryPoints": provider.getEntryPoints,
|
2015-11-13 10:50:32 +00:00
|
|
|
"getFrontendRule": provider.getFrontendRule,
|
|
|
|
"replace": replace,
|
2015-09-10 20:54:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// filter containers
|
2016-07-14 09:32:15 +00:00
|
|
|
filteredContainers := fun.Filter(func(container dockertypes.ContainerJSON) bool {
|
|
|
|
return provider.containerFilter(container, provider.ExposedByDefault)
|
|
|
|
}, containersInspected).([]dockertypes.ContainerJSON)
|
2015-09-10 20:54:37 +00:00
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
frontends := map[string][]dockertypes.ContainerJSON{}
|
2015-09-10 20:54:37 +00:00
|
|
|
for _, container := range filteredContainers {
|
2016-06-06 19:59:58 +00:00
|
|
|
frontendName := provider.getFrontendName(container)
|
|
|
|
frontends[frontendName] = append(frontends[frontendName], container)
|
2015-09-07 08:38:58 +00:00
|
|
|
}
|
2015-09-09 14:49:51 +00:00
|
|
|
|
|
|
|
templateObjects := struct {
|
2016-04-08 12:20:54 +00:00
|
|
|
Containers []dockertypes.ContainerJSON
|
|
|
|
Frontends map[string][]dockertypes.ContainerJSON
|
2015-09-09 15:50:02 +00:00
|
|
|
Domain string
|
2015-09-07 08:38:58 +00:00
|
|
|
}{
|
2015-09-10 20:54:37 +00:00
|
|
|
filteredContainers,
|
2015-10-23 07:49:19 +00:00
|
|
|
frontends,
|
2015-09-09 15:10:43 +00:00
|
|
|
provider.Domain,
|
2015-09-07 08:38:58 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 10:50:32 +00:00
|
|
|
configuration, err := provider.getConfiguration("templates/docker.tmpl", DockerFuncMap, templateObjects)
|
2015-09-07 08:38:58 +00:00
|
|
|
if err != nil {
|
2015-11-13 10:50:32 +00:00
|
|
|
log.Error(err)
|
2015-09-07 08:38:58 +00:00
|
|
|
}
|
2015-11-13 10:50:32 +00:00
|
|
|
return configuration
|
|
|
|
}
|
2015-09-07 08:38:58 +00:00
|
|
|
|
2016-07-14 09:32:15 +00:00
|
|
|
func (provider *Docker) containerFilter(container dockertypes.ContainerJSON, exposedByDefaultFlag bool) bool {
|
2016-05-28 22:16:57 +00:00
|
|
|
_, err := strconv.Atoi(container.Config.Labels["traefik.port"])
|
|
|
|
if len(container.NetworkSettings.Ports) == 0 && err != nil {
|
|
|
|
log.Debugf("Filtering container without port and no traefik.port label %s", container.Name)
|
2015-11-13 10:50:32 +00:00
|
|
|
return false
|
2015-09-07 08:38:58 +00:00
|
|
|
}
|
2015-11-13 10:50:32 +00:00
|
|
|
if len(container.NetworkSettings.Ports) > 1 && err != nil {
|
|
|
|
log.Debugf("Filtering container with more than 1 port and no traefik.port label %s", container.Name)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-07-14 09:32:15 +00:00
|
|
|
if !isContainerEnabled(container, exposedByDefaultFlag) {
|
2015-11-13 10:50:32 +00:00
|
|
|
log.Debugf("Filtering disabled container %s", container.Name)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-06-06 19:59:58 +00:00
|
|
|
constraintTags := strings.Split(container.Config.Labels["traefik.tags"], ",")
|
2016-06-11 17:05:54 +00:00
|
|
|
if ok, failingConstraint := provider.MatchConstraints(constraintTags); !ok {
|
2016-06-06 19:59:58 +00:00
|
|
|
if failingConstraint != nil {
|
|
|
|
log.Debugf("Container %v pruned by '%v' constraint", container.Name, failingConstraint.String())
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2015-11-13 10:50:32 +00:00
|
|
|
return true
|
2015-09-09 14:49:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getFrontendName(container dockertypes.ContainerJSON) string {
|
2015-10-23 07:49:19 +00:00
|
|
|
// Replace '.' with '-' in quoted keys because of this issue https://github.com/BurntSushi/toml/issues/78
|
2016-03-27 00:05:17 +00:00
|
|
|
return normalize(provider.getFrontendRule(container))
|
2015-10-23 07:49:19 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 10:50:32 +00:00
|
|
|
// GetFrontendRule returns the frontend rule for the specified container, using
|
|
|
|
// it's label. It returns a default one (Host) if the label is not present.
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getFrontendRule(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.frontend.rule"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
2016-06-01 14:47:39 +00:00
|
|
|
return "Host:" + provider.getSubDomain(container.Name) + "." + provider.Domain
|
2015-11-13 10:50:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getBackend(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.backend"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
2016-03-27 00:05:17 +00:00
|
|
|
return normalize(container.Name)
|
2015-11-13 10:50:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 05:11:17 +00:00
|
|
|
func (provider *Docker) getIPAddress(container dockertypes.ContainerJSON) string {
|
|
|
|
if label, err := getLabel(container, "traefik.docker.network"); err == nil && label != "" {
|
|
|
|
networks := container.NetworkSettings.Networks
|
|
|
|
if networks != nil {
|
|
|
|
network := networks[label]
|
|
|
|
if network != nil {
|
|
|
|
return network.IPAddress
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-05 09:44:30 +00:00
|
|
|
|
|
|
|
// If net==host, quick n' dirty, we return 127.0.0.1
|
|
|
|
// This will work locally, but will fail with swarm.
|
|
|
|
if container.HostConfig != nil && "host" == container.HostConfig.NetworkMode {
|
|
|
|
return "127.0.0.1"
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, network := range container.NetworkSettings.Networks {
|
2016-06-01 05:11:17 +00:00
|
|
|
return network.IPAddress
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getPort(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.port"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
|
|
|
for key := range container.NetworkSettings.Ports {
|
|
|
|
return key.Port()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getWeight(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.weight"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
2016-03-27 00:05:17 +00:00
|
|
|
return "1"
|
2015-11-13 10:50:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getDomain(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.domain"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
|
|
|
return provider.Domain
|
2015-10-23 07:49:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getProtocol(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if label, err := getLabel(container, "traefik.protocol"); err == nil {
|
|
|
|
return label
|
|
|
|
}
|
|
|
|
return "http"
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getPassHostHeader(container dockertypes.ContainerJSON) string {
|
2015-11-13 10:50:32 +00:00
|
|
|
if passHostHeader, err := getLabel(container, "traefik.frontend.passHostHeader"); err == nil {
|
|
|
|
return passHostHeader
|
|
|
|
}
|
2016-05-10 11:43:24 +00:00
|
|
|
return "true"
|
2015-11-13 10:50:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-06 20:30:23 +00:00
|
|
|
func (provider *Docker) getPriority(container dockertypes.ContainerJSON) string {
|
|
|
|
if priority, err := getLabel(container, "traefik.frontend.priority"); err == nil {
|
|
|
|
return priority
|
|
|
|
}
|
|
|
|
return "0"
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func (provider *Docker) getEntryPoints(container dockertypes.ContainerJSON) []string {
|
2016-02-01 15:08:58 +00:00
|
|
|
if entryPoints, err := getLabel(container, "traefik.frontend.entryPoints"); err == nil {
|
|
|
|
return strings.Split(entryPoints, ",")
|
|
|
|
}
|
|
|
|
return []string{}
|
|
|
|
}
|
|
|
|
|
2016-07-14 09:32:15 +00:00
|
|
|
func isContainerEnabled(container dockertypes.ContainerJSON, exposedByDefault bool) bool {
|
|
|
|
return exposedByDefault && container.Config.Labels["traefik.enable"] != "false" || container.Config.Labels["traefik.enable"] == "true"
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func getLabel(container dockertypes.ContainerJSON, label string) (string, error) {
|
2015-09-09 14:49:51 +00:00
|
|
|
for key, value := range container.Config.Labels {
|
2015-10-23 07:49:19 +00:00
|
|
|
if key == label {
|
|
|
|
return value, nil
|
2015-09-09 14:49:51 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-23 07:49:19 +00:00
|
|
|
return "", errors.New("Label not found:" + label)
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:20:54 +00:00
|
|
|
func getLabels(container dockertypes.ContainerJSON, labels []string) (map[string]string, error) {
|
2015-11-05 14:14:25 +00:00
|
|
|
var globalErr error
|
2015-10-26 23:26:35 +00:00
|
|
|
foundLabels := map[string]string{}
|
|
|
|
for _, label := range labels {
|
2015-11-13 10:50:32 +00:00
|
|
|
foundLabel, err := getLabel(container, label)
|
2015-11-05 14:14:25 +00:00
|
|
|
// Error out only if one of them is defined.
|
2015-11-01 18:29:47 +00:00
|
|
|
if err != nil {
|
2015-11-05 14:14:25 +00:00
|
|
|
globalErr = errors.New("Label not found: " + label)
|
|
|
|
continue
|
2015-10-26 23:26:35 +00:00
|
|
|
}
|
2015-11-01 18:29:47 +00:00
|
|
|
foundLabels[label] = foundLabel
|
2015-11-05 14:14:25 +00:00
|
|
|
|
2015-10-26 23:26:35 +00:00
|
|
|
}
|
2015-11-05 14:14:25 +00:00
|
|
|
return foundLabels, globalErr
|
2015-10-26 23:26:35 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 17:39:38 +00:00
|
|
|
func listContainers(ctx context.Context, dockerClient client.APIClient) ([]dockertypes.ContainerJSON, error) {
|
|
|
|
containerList, err := dockerClient.ContainerList(ctx, dockertypes.ContainerListOptions{})
|
2016-04-08 12:20:54 +00:00
|
|
|
if err != nil {
|
|
|
|
return []dockertypes.ContainerJSON{}, err
|
|
|
|
}
|
|
|
|
containersInspected := []dockertypes.ContainerJSON{}
|
2015-10-23 07:49:19 +00:00
|
|
|
|
2015-11-13 10:50:32 +00:00
|
|
|
// get inspect containers
|
|
|
|
for _, container := range containerList {
|
2016-06-08 17:39:38 +00:00
|
|
|
containerInspected, err := dockerClient.ContainerInspect(ctx, container.ID)
|
2016-04-08 12:20:54 +00:00
|
|
|
if err != nil {
|
2016-06-20 10:15:31 +00:00
|
|
|
log.Warnf("Failed to inspect container %s, error: %s", container.ID, err)
|
2016-06-08 17:39:38 +00:00
|
|
|
} else {
|
|
|
|
containersInspected = append(containersInspected, containerInspected)
|
2016-04-08 12:20:54 +00:00
|
|
|
}
|
2015-10-23 07:49:19 +00:00
|
|
|
}
|
2016-04-08 12:20:54 +00:00
|
|
|
return containersInspected, nil
|
2015-09-12 13:10:03 +00:00
|
|
|
}
|
2016-05-31 21:23:23 +00:00
|
|
|
|
|
|
|
// Escape beginning slash "/", convert all others to dash "-"
|
2016-06-01 14:47:39 +00:00
|
|
|
func (provider *Docker) getSubDomain(name string) string {
|
2016-05-31 21:23:23 +00:00
|
|
|
return strings.Replace(strings.TrimPrefix(name, "/"), "/", "-", -1)
|
|
|
|
}
|