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
|
||||
func deployWorker(image string, identifier string, env []string) {
|
||||
// figure out current container id
|
||||
containerId := getThisContainerId()
|
||||
|
||||
// Binds is the actual "-v" volume.
|
||||
hostConfig := &container.HostConfig{
|
||||
NetworkMode: container.NetworkMode(fmt.Sprintf("container:%s", containerId)),
|
||||
IpcMode: container.IpcMode(fmt.Sprintf("container:%s", containerId)),
|
||||
LogConfig: container.LogConfig{
|
||||
Type: "json-file",
|
||||
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/
|
||||
config := &container.Config{
|
||||
Image: image,
|
||||
|
||||
@@ -426,18 +426,23 @@ func getThisContainerId() string {
|
||||
|
||||
// Deploys the internal worker whenever something happens
|
||||
func deployApp(cli *dockerclient.Client, image string, identifier string, env []string) error {
|
||||
// figure out current container id
|
||||
containerId := getThisContainerId()
|
||||
|
||||
// form basic hostConfig
|
||||
hostConfig := &container.HostConfig{
|
||||
NetworkMode: container.NetworkMode(fmt.Sprintf("container:%s", containerId)),
|
||||
IpcMode: container.IpcMode(fmt.Sprintf("container:%s", containerId)),
|
||||
LogConfig: container.LogConfig{
|
||||
Type: "json-file",
|
||||
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{
|
||||
Image: image,
|
||||
Env: env,
|
||||
|
||||
Reference in New Issue
Block a user