diff --git a/kiwi/container_image.py b/kiwi/container_image.py
new file mode 100644
index 00000000..2186a948
--- /dev/null
+++ b/kiwi/container_image.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
+#
+# This file is part of kiwi.
+#
+# kiwi is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# kiwi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kiwi. If not, see
+#
+# project
+from container_image_docker import ContainerImageDocker
+
+from exceptions import (
+ KiwiContainerImageSetupError
+)
+
+
+class ContainerImage(object):
+ """
+ Container Image factory
+ """
+ def __new__(self, name, root_dir):
+ if name == 'docker':
+ return ContainerImageDocker(root_dir)
+ else:
+ raise KiwiContainerImageSetupError(
+ 'Support for %s container not implemented' % name
+ )
diff --git a/kiwi/container_image_docker.py b/kiwi/container_image_docker.py
new file mode 100644
index 00000000..359c2871
--- /dev/null
+++ b/kiwi/container_image_docker.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
+#
+# This file is part of kiwi.
+#
+# kiwi is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# kiwi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kiwi. If not, see
+#
+# project
+from command import Command
+from archive_tar import ArchiveTar
+
+
+class ContainerImageDocker(object):
+ """
+ Create docker container from a root directory
+ """
+ def __init__(self, root_dir):
+ self.root_dir = root_dir
+
+ def create(self, filename):
+ exclude_list = [
+ 'image', '.profile', '.kconfig', 'var/cache/kiwi', 'boot'
+ ]
+ # replace potential suffix from filename because
+ # it is added by the archive creation call
+ archive = ArchiveTar(
+ filename.replace('.xz', '')
+ )
+ archive.create_xz_compressed(
+ source_dir=self.root_dir, exclude=exclude_list
+ )
diff --git a/kiwi/exceptions.py b/kiwi/exceptions.py
index 4b6215c6..69e3593e 100644
--- a/kiwi/exceptions.py
+++ b/kiwi/exceptions.py
@@ -89,6 +89,10 @@ class KiwiContainerSetupError(KiwiError):
pass
+class KiwiContainerImageSetupError(KiwiError):
+ pass
+
+
class KiwiDataStructureError(KiwiError):
pass
diff --git a/test/unit/container_image_docker_test.py b/test/unit/container_image_docker_test.py
new file mode 100644
index 00000000..c16aff8f
--- /dev/null
+++ b/test/unit/container_image_docker_test.py
@@ -0,0 +1,26 @@
+from nose.tools import *
+from mock import patch
+
+import mock
+
+import nose_helper
+
+from kiwi.exceptions import *
+from kiwi.container_image_docker import ContainerImageDocker
+
+
+class TestContainerImageDocker(object):
+ def setup(self):
+ self.docker = ContainerImageDocker('root_dir')
+
+ @patch('kiwi.container_image_docker.ArchiveTar')
+ def test_create(self, mock_archive):
+ archive = mock.Mock()
+ mock_archive.return_value = archive
+ self.docker.create('result.tar.xz')
+ mock_archive.assert_called_once_with('result.tar')
+ archive.create_xz_compressed.assert_called_once_with(
+ exclude=[
+ 'image', '.profile', '.kconfig', 'var/cache/kiwi', 'boot'
+ ], source_dir='root_dir'
+ )
diff --git a/test/unit/container_image_test.py b/test/unit/container_image_test.py
new file mode 100644
index 00000000..c8900729
--- /dev/null
+++ b/test/unit/container_image_test.py
@@ -0,0 +1,20 @@
+from nose.tools import *
+from mock import patch
+
+import mock
+
+import nose_helper
+
+from kiwi.exceptions import *
+from kiwi.container_image import ContainerImage
+
+
+class TestContainerImage(object):
+ @raises(KiwiContainerImageSetupError)
+ def test_container_image_not_implemented(self):
+ ContainerImage('foo', 'root_dir')
+
+ @patch('kiwi.container_image.ContainerImageDocker')
+ def test_container_image_docker(self, mock_docker):
+ ContainerImage('docker', 'root_dir')
+ mock_docker.assert_called_once_with('root_dir')