forked from LaconicNetwork/kompose
Merge pull request #1141 from hangyan/container-name
Fix container_name set error
This commit is contained in:
commit
ab28d7500b
@ -380,7 +380,7 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
|||||||
// fillTemplate fills the pod template with the value calculated from config
|
// fillTemplate fills the pod template with the value calculated from config
|
||||||
fillTemplate := func(template *api.PodTemplateSpec) error {
|
fillTemplate := func(template *api.PodTemplateSpec) error {
|
||||||
if len(service.ContainerName) > 0 {
|
if len(service.ContainerName) > 0 {
|
||||||
template.Spec.Containers[0].Name = service.ContainerName
|
template.Spec.Containers[0].Name = FormatContainerName(service.ContainerName)
|
||||||
}
|
}
|
||||||
template.Spec.Containers[0].Env = envs
|
template.Spec.Containers[0].Env = envs
|
||||||
template.Spec.Containers[0].Command = service.Command
|
template.Spec.Containers[0].Command = service.Command
|
||||||
@ -650,3 +650,10 @@ func FormatFileName(name string) string {
|
|||||||
envName = strings.Replace(envName, "_", "-", -1)
|
envName = strings.Replace(envName, "_", "-", -1)
|
||||||
return envName
|
return envName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FormatContainerName format Container name
|
||||||
|
func FormatContainerName(name string) string {
|
||||||
|
name = strings.Replace(name, "_", "-", -1)
|
||||||
|
return name
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ services:
|
|||||||
command: bundle exec thin -p 3000
|
command: bundle exec thin -p 3000
|
||||||
# command: ["bundle", "exec", "thin", "-p", "3000"]
|
# command: ["bundle", "exec", "thin", "-p", "3000"]
|
||||||
|
|
||||||
container_name: my-web-container
|
container_name: my_web-container
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user