export-docker
export-docker copied to clipboard
Doesn't use API; needs root; doesn't work with current version of docker
The docker binary exposes all the functions needed to do this without root access and without direct access to the docker paths. The current approach doesn't seem to be portable. Why can't the docker export command be used?
sudo ./export-container.py 9d8291fb57d4 test
Exporting Docker container to a lxc container
('Docker container id: ', '9d8291fb57d4')
('New container name: ', 'test')
('Full container id ', '9d8291fb57d474082ad4e91ab6625e5e9b8f2da673ede41bfad8647e13bf447b')
Container exists [/var/lib/docker/containers/9d8291fb57d474082ad4e91ab6625e5e9b8f2da673ede41bfad8647e13bf447b]? True
Traceback (most recent call last):
File "./export-container.py", line 208, in <module>
main()
File "./export-container.py", line 199, in main
container.is_valid_container()
File "./export-container.py", line 50, in is_valid_container
self.lxc_rootfs_exists()
File "./export-container.py", line 64, in lxc_rootfs_exists
lines = tuple(open(self.config, "r"))
IOError: [Errno 2] No such file or directory: '/var/lib/docker/containers/9d8291fb57d474082ad4e91ab6625e5e9b8f2da673ede41bfad8647e13bf447b/config.lxc'
README.md export-container.py
$
Your README is missing some vital information. Such as that you need to create an lxc config file inside your container root - I'm not sure if that is the best place...
It was created 4 years ago, just for fun, to get some knowledge of docker images and how to run using plain lxc.
Certainly, it won't work on current releases.