improve work with Kubernetes
This commit is contained in:
@@ -106,7 +106,7 @@ func getThisContainerId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fCol != "" {
|
if fCol != "" {
|
||||||
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f%s", fCol)
|
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f%s | grep -o -E '[0-9A-z]{64}'", fCol)
|
||||||
out, err := exec.Command("bash", "-c", cmd).Output()
|
out, err := exec.Command("bash", "-c", cmd).Output()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
containerId = strings.TrimSpace(string(out))
|
containerId = strings.TrimSpace(string(out))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ var containerId string
|
|||||||
// form container id of current running container
|
// form container id of current running container
|
||||||
func getThisContainerId() string {
|
func getThisContainerId() string {
|
||||||
id := ""
|
id := ""
|
||||||
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3")
|
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3 | grep -o -E '[0-9A-z]{64}'")
|
||||||
out, err := exec.Command("bash", "-c", cmd).Output()
|
out, err := exec.Command("bash", "-c", cmd).Output()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
id = strings.TrimSpace(string(out))
|
id = strings.TrimSpace(string(out))
|
||||||
@@ -861,6 +861,7 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
|||||||
}
|
}
|
||||||
|
|
||||||
// form container id and use it as network source if it's not empty
|
// form container id and use it as network source if it's not empty
|
||||||
|
containerId = getThisContainerId()
|
||||||
if containerId != "" {
|
if containerId != "" {
|
||||||
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
|
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user