volumes path, on create, should be the one inside the container

not from the host
This commit is contained in:
Nicolas Delaby 2015-05-18 14:24:41 +02:00
parent a8af238633
commit df48ac2b91
2 changed files with 42 additions and 1 deletions

View File

@ -1392,7 +1392,8 @@ def running(name,
# Using bind mounts requries mountpoints to be specified at the
# time the container is created, so we need to add them to the
# create_kwargs.
create_kwargs['volumes'] = list(runtime_kwargs['binds'])
create_kwargs['volumes'] = [bind_conf['bind'] for bind_conf in
runtime_kwargs['binds'].values()]
if runtime_kwargs.get('port_bindings') is not None \
and create_kwargs.get('ports') is None:
create_kwargs['ports'] = ','.join(

View File

@ -0,0 +1,40 @@
from salttesting import TestCase
from salttesting.mock import MagicMock, Mock, patch
import salt.states.dockerng
class DockerngTestCase(TestCase):
@patch.dict(salt.modules.dockerng.__dict__, {'__context__': {}})
@patch.dict(salt.modules.dockerng.__dict__, {'__salt__': MagicMock()})
@patch.dict(salt.states.dockerng.__dict__, {'__context__': {}})
@patch.dict(salt.states.dockerng.__dict__, {'__context__': {}})
@patch.dict(salt.states.dockerng.__dict__, {'__opts__': {'test': False}})
def test_running(self):
dockerng_create = Mock()
dockerng_start = Mock()
__salt__ = {'dockerng.list_containers': MagicMock(),
'dockerng.list_tags': MagicMock(),
'dockerng.pull': MagicMock(),
'dockerng.state': MagicMock(),
'dockerng.create': dockerng_create,
'dockerng.start': dockerng_start,
}
with patch.dict(salt.states.dockerng.__dict__,
{'__salt__': __salt__}):
result = salt.states.dockerng.running(
'cont',
image='image:latest',
binds=['/host-0:/container-0:ro'])
dockerng_create.assert_called_with(
'image:latest',
validate_input=False,
name='cont',
volumes=['/container-0'],
client_timeout=60)
dockerng_start.assert_called_with(
'cont',
binds={'/host-0': {'bind': '/container-0', 'ro': True}},
validate_ip_addrs=False,
validate_input=False)