Converting Docker image to LXD


(Ron Kelley) #1

Not sure if this has been asked before, but is it possible to convert a running docker image to LXD?

Background: We need to build a special module for nginx (pagepseed) for Alpine Linux, and the instructions on the web are very sparse. There is a docker build config file to get this done, but I keep running into issues using those instructions on a standard LXD Alpine image. It seems the standard Alpine image for docker has some extra packages installed that are not included in the LXD baseline image. My Alpine “apk” skills are very lacking otherwise I would have solved this by now.

One way forward is just to spin up the docker image them convert that to an LXD image. Any other suggestions?


#2

This question has been asked before.
The issue is that Docker is for application containers and LXD is for system containers.
There is no 1 to 1 conversion between the two, and if there was some tool that would somewhat help,
it would still need from you to get into there to fix things.
Normally, you should be able to read the Dockerfile and extract the commands that are needed and apply them to the LXD Alpine container image.
Have a look at https://github.com/veggiemonk/awesome-docker in case you find a relevant tool or even a community that could help you.


#3

you can run docker inside a container
see for example this previous post
don’t forget to set the container as nested (lxc config)


(Ron Kelley) #4

Thanks for the info. I figured it would be difficult to convert a docker image to LXD for the exact reason Simos mentioned (no real init system - just run a program).

At this point, I will just try to figure out how to compile the program on a native LXD image.

Thanks.


#5

To run docker in a LXD container, you also need to figure out what storage driver will be used. Because the default settings with ZFS for LXD does not offer a good option for docker (VFS storage driver). There are some discussions on this list on how to resolve this by switching LXD to btrfs.


(Ron Kelley) #6

Thanks Simos. I use btrfs exclusively for all our containers for the fast snapshotting capabilities.

We probably won’t do docker anytime soon since our infrastructure automation tools are already written for LXD.