Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
0f4e2ae4
Commit
0f4e2ae4
authored
Sep 26, 2018
by
Samuel GAIST
Browse files
[docker] Implement support for custom network
parent
dd0b9f97
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/core/execution/docker.py
View file @
0f4e2ae4
...
...
@@ -37,6 +37,7 @@ import os
import
requests
import
simplejson
import
zmq
import
docker
import
logging
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -223,6 +224,7 @@ class DockerExecutor(RemoteExecutor):
databases_container
=
None
datasets_uid
=
self
.
data
.
pop
(
'datasets_uid'
,
None
)
network_name
=
self
.
data
.
pop
(
'network_name'
,
'bridge'
)
if
len
(
self
.
databases
)
>
0
:
...
...
@@ -272,6 +274,7 @@ class DockerExecutor(RemoteExecutor):
databases_container
=
self
.
host
.
create_container
(
databases_environment
,
cmd
)
databases_container
.
uid
=
datasets_uid
databases_container
.
network_name
=
network_name
# Specify the volumes to mount inside the container
databases_container
.
add_volume
(
databases_configuration_path
,
'/beat/prefix'
)
...
...
@@ -298,6 +301,14 @@ class DockerExecutor(RemoteExecutor):
cmd
=
[
x
if
not
x
.
startswith
(
'0.0.0.0:'
)
else
'0.0.0.0:%d'
%
database_port
for
x
in
cmd
]
databases_container
.
command
=
cmd
database_ip
=
self
.
host
.
ip
client
=
docker
.
from_env
()
for
container
in
client
.
containers
.
list
():
newtwork_settings
=
container
.
attrs
[
'NetworkSettings'
]
for
port
,
mapping
in
newtwork_settings
[
'Ports'
].
items
():
if
port
.
startswith
(
'%d'
%
database_port
):
database_ip
=
newtwork_settings
[
'Networks'
][
network_name
][
'IPAddress'
]
#----- Instantiate the algorithm container
...
...
@@ -314,7 +325,7 @@ class DockerExecutor(RemoteExecutor):
]
if
len
(
self
.
databases
)
>
0
:
cmd
.
append
(
'tcp://'
+
self
.
host
.
ip
+
':%d'
%
database_port
)
cmd
.
append
(
'tcp://'
+
database_
ip
+
':%d'
%
database_port
)
if
logger
.
getEffectiveLevel
()
<=
logging
.
DEBUG
:
cmd
.
insert
(
1
,
'--debug'
)
...
...
@@ -322,6 +333,7 @@ class DockerExecutor(RemoteExecutor):
# Creation of the container
algorithm_container
=
self
.
host
.
create_container
(
processing_environment
,
cmd
)
algorithm_container
.
uid
=
datasets_uid
algorithm_container
.
network_name
=
network_name
# Volumes
algorithm_container
.
add_volume
(
configuration_path
,
'/beat/prefix'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment