5

I have made a docker container meant with some code for deployment. However, I realised that the structure of the project I'm working with, it's more suitable to deploy a full ISO image, instead of running docker on top of a cloud VM running stock debian, leading to unnecessary layers of virtualization.

I know that dockers are meant to be deployed on kubernetes, but before diving into that route, is there a simple way to convert a deb9 docker image into a full deb9 OS image? Like an opposite of docker import?

Larry Cai
  • 881
  • 1
  • 11
  • 24

2 Answers2

9

You can convert your docker container to an full os image. An Dockerfile debian example would be

FROM debian:stretch
RUN apt-get -y install --no-install-recommends \
  linux-image-amd64 \
  systemd-sysv

In principal you have to install a kernel and an init system.

Full instructions can be found github

Florian Berndl
  • 1,136
  • 8
  • 27
3

Docker images don't contain a Linux kernel and aren't configured to do things like run a full init system or go out and get their network configuration, so this won't work well.

Put differently: the same mismatch that makes docker import not really work well because the resulting container will have too much stuff and won't be set up for Docker, means you can't export a container or image into a VM and expect it to work in that environment.

But! If you've written a Dockerfile for your image, that's very close to saying "I'm going to start from this base Linux distribution and run this shell script to get an image". Tools like Packer are set up to take a base Linux VM image, run some sort of provisioner, and create a new image. If you have a good Docker setup already, and decide a VM is a better fit, you're probably done a lot of the leg-work already to have an automated build of your VM image.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Instead of using the dockerfile to install programs when the container 'boots', I manually installed programs and then committed the whole container. So I'm basically out of luck? – Larry Cai Jan 29 '19 at 03:35