'Recreate a container.
The original container is renamed to a temporary name so that data
volumes can be copied to the new container, before the original
container is removed.'

def recreate_container(self, container, timeout=None, attach_logs=False, start_new_container=True):

    log.info((u'Recreating    %s' % container.name))
    container.stop(timeout=self.stop_timeout(timeout))
    container.rename_to_tmp_name()
    new_container = self.create_container(previous_container=container, number=container.labels.get(LABEL_CONTAINER_NUMBER), quiet=True)
    if attach_logs:
        new_container.attach_log_stream()
    if start_new_container:
        self.start_container(new_container)
    container.remove()
    return new_container
