siemonster :: handle empty calculated self container id
This commit is contained in:
@@ -99,13 +99,8 @@ func getThisContainerId() string {
|
|||||||
|
|
||||||
// Deploys the internal worker whenever something happens
|
// Deploys the internal worker whenever something happens
|
||||||
func deployWorker(image string, identifier string, env []string) {
|
func deployWorker(image string, identifier string, env []string) {
|
||||||
// figure out current container id
|
|
||||||
containerId := getThisContainerId()
|
|
||||||
|
|
||||||
// Binds is the actual "-v" volume.
|
// Binds is the actual "-v" volume.
|
||||||
hostConfig := &container.HostConfig{
|
hostConfig := &container.HostConfig{
|
||||||
NetworkMode: container.NetworkMode(fmt.Sprintf("container:%s", containerId)),
|
|
||||||
IpcMode: container.IpcMode(fmt.Sprintf("container:%s", containerId)),
|
|
||||||
LogConfig: container.LogConfig{
|
LogConfig: container.LogConfig{
|
||||||
Type: "json-file",
|
Type: "json-file",
|
||||||
Config: map[string]string{},
|
Config: map[string]string{},
|
||||||
@@ -115,6 +110,15 @@ func deployWorker(image string, identifier string, env []string) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// form container id and use it as network source if it's not empty
|
||||||
|
containerId := getThisContainerId()
|
||||||
|
if containerId != "" {
|
||||||
|
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
|
||||||
|
hostConfig.IpcMode = container.IpcMode(fmt.Sprintf("container:%s", containerId))
|
||||||
|
} else {
|
||||||
|
log.Printf("[WARNING] Empty determined container id, continue without NetworkMode/IpcMode")
|
||||||
|
}
|
||||||
|
|
||||||
// ROFL: https://docker-py.readthedocs.io/en/1.4.0/volumes/
|
// ROFL: https://docker-py.readthedocs.io/en/1.4.0/volumes/
|
||||||
config := &container.Config{
|
config := &container.Config{
|
||||||
Image: image,
|
Image: image,
|
||||||
|
|||||||
@@ -426,18 +426,23 @@ func getThisContainerId() string {
|
|||||||
|
|
||||||
// Deploys the internal worker whenever something happens
|
// Deploys the internal worker whenever something happens
|
||||||
func deployApp(cli *dockerclient.Client, image string, identifier string, env []string) error {
|
func deployApp(cli *dockerclient.Client, image string, identifier string, env []string) error {
|
||||||
// figure out current container id
|
// form basic hostConfig
|
||||||
containerId := getThisContainerId()
|
|
||||||
|
|
||||||
hostConfig := &container.HostConfig{
|
hostConfig := &container.HostConfig{
|
||||||
NetworkMode: container.NetworkMode(fmt.Sprintf("container:%s", containerId)),
|
|
||||||
IpcMode: container.IpcMode(fmt.Sprintf("container:%s", containerId)),
|
|
||||||
LogConfig: container.LogConfig{
|
LogConfig: container.LogConfig{
|
||||||
Type: "json-file",
|
Type: "json-file",
|
||||||
Config: map[string]string{},
|
Config: map[string]string{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// form container id and use it as network source if it's not empty
|
||||||
|
containerId := getThisContainerId()
|
||||||
|
if containerId != "" {
|
||||||
|
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
|
||||||
|
hostConfig.IpcMode = container.IpcMode(fmt.Sprintf("container:%s", containerId))
|
||||||
|
} else {
|
||||||
|
log.Printf("[WARNING] Empty determined container id, continue without NetworkMode/IpcMode")
|
||||||
|
}
|
||||||
|
|
||||||
config := &container.Config{
|
config := &container.Config{
|
||||||
Image: image,
|
Image: image,
|
||||||
Env: env,
|
Env: env,
|
||||||
|
|||||||
Reference in New Issue
Block a user