def test_create_container_with_volumes_from(self): volume_service = self.create_service('data') volume_container_1 = volume_service.create_container() volume_container_2 = Container.create(self.client, image='busybox:latest', command=["/bin/sleep", "300"]) host_service = self.create_service('host', volumes_from=[volume_service, volume_container_2]) host_container = host_service.create_container() host_service.start_container(host_container) self.assertIn(volume_container_1.id, host_container.inspect()['HostConfig']['VolumesFrom']) self.assertIn(volume_container_2.id, host_container.inspect()['HostConfig']['VolumesFrom'])
def test_create_container_with_volumes_from(self): volume_service = self.create_service('data') volume_container_1 = volume_service.create_container() volume_container_2 = Container.create(self.client, image='busybox:latest', command=["/bin/sleep", "300"]) host_service = self.create_service( 'host', volumes_from=[volume_service, volume_container_2]) host_container = host_service.create_container() host_service.start_container(host_container) self.assertIn(volume_container_1.id, host_container.inspect()['HostConfig']['VolumesFrom']) self.assertIn(volume_container_2.id, host_container.inspect()['HostConfig']['VolumesFrom'])
def get_config(self): tmp_container = Container.create(self.client, image=self.image_name, command='true') try: res = self.client.copy(tmp_container.name, '/karakuri.yml') except APIError: work_dir = tmp_container.inspect()['Config']['WorkingDir'] res = self.client.copy(tmp_container.name, '{0}/karakuri.yml'.format(work_dir)) tmp_container.remove() io = BytesIO() io.write(res.data) io.seek(0) tar = tarfile.open(mode='r:', fileobj=io) config_str = tar.extractfile('karakuri.yml').read() config_str = Template(config_str).substitute(TAG=self.tag) return yaml.load(config_str)
def test_volumes_from_container(self): data_container = Container.create( self.client, image='busybox:latest', volumes=['/var/data'], name='figtest_data_container', ) project = Project.from_config( name='figtest', config={ 'db': { 'image': 'busybox:latest', 'volumes_from': ['figtest_data_container'], }, }, client=self.client, ) db = project.get_service('db') self.assertEqual(db.volumes_from, [data_container])
def test_volumes_from_container(self): data_container = Container.create( self.client, image='busybox:latest', volumes=['/var/data'], name='figtest_data_container', ) project = Project.from_config( name='figtest', config={ 'db': { 'image': 'busybox:latest', 'volumes_from': ['figtest_data_container'], }, }, client=self.client, ) db = project.get_service('db') self.assertEqual(db.volumes_from, [data_container])