Add k3d- prefix to docker network name

Should make sense since all container names are with the same prefix.
pull/72/head
Andy Zhou 5 years ago
parent df5cc1da84
commit 1f7d234c80
  1. 4
      cli/container.go
  2. 6
      cli/network.go

@ -105,7 +105,7 @@ func createServer(verbose bool, image string, apiPort string, args []string, env
networkingConfig := &network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
name: {
k3dNetworkName(name): {
Aliases: []string{containerName},
},
},
@ -175,7 +175,7 @@ func createWorker(verbose bool, image string, args []string, env []string, name
networkingConfig := &network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
name: {
k3dNetworkName(name): {
Aliases: []string{containerName},
},
},

@ -10,6 +10,10 @@ import (
"github.com/docker/docker/client"
)
func k3dNetworkName(clusterName string) string {
return fmt.Sprintf("k3d-%s", clusterName)
}
// createClusterNetwork creates a docker network for a cluster that will be used
// to let the server and worker containers communicate with each other easily.
func createClusterNetwork(clusterName string) (string, error) {
@ -36,7 +40,7 @@ func createClusterNetwork(clusterName string) (string, error) {
}
// create the network with a set of labels and the cluster name as network name
resp, err := docker.NetworkCreate(ctx, clusterName, types.NetworkCreate{
resp, err := docker.NetworkCreate(ctx, k3dNetworkName(clusterName), types.NetworkCreate{
Labels: map[string]string{
"app": "k3d",
"cluster": clusterName,

Loading…
Cancel
Save