2

It is possible to create images from scratch using Packer by downloading an ISO from the internet.

Aim: to create Docker images by downloading an ISO using Packer

Attempts

Attempt 1

It is possible to import a Docker image

[username@hostname]$ cat docker.json 
{
    "builders":[{
        "type": "docker",
        "image": "ubuntu",
        "export_path": "image.tar"
    }]
}

using Packer:

[username@hostname packer]$ packer build docker.json 
docker output will be in this color.

==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: ubuntu
==> docker: Starting docker container...
==> docker: Exporting the container
==> docker: Killing the container: 6e0e5488d8b4f97667123ea965a561c91122f3efc6ef4b86a7c40560714d6577
Build 'docker' finished.

==> Builds finished. The artifacts of successful builds are:
--> docker: Exported Docker file: image.tar

Attempt 2

Changing the builder type of a packer.json that is used to create a virtualbox image to docker results in:

[username@hostname]$ packer build docker-scratch.json 
docker output will be in this color.

15 error(s) occurred:

* unknown configuration key: "boot_command"
* unknown configuration key: "boot_wait"
...
* unknown configuration key: "vboxmanage"
* unknown configuration key: "virtualbox_version_file"

Problem

However, if a docker image needs to be created several base images could be downloaded, but is it also possible to download an ISO and to transform that to a docker image?


Reference

Basic Example: Export

enter image description here

030
  • 5,901
  • 13
  • 68
  • 110

1 Answers1

1

Yes, it is possible to bootstrap your own images. Check the mkimage-* scripts from the contrib directory.

Florin Asăvoaie
  • 7,057
  • 23
  • 35
  • This means that this is done without Packer? How to subsequently import it using Packer? Run packer from the parent directory where the created image resides? – 030 Dec 01 '15 at 13:05
  • Have you read any of the scripts and how they work? These scripts will allow you to create a image that is self-dependent and will not download other images when using it. From there on, you just use it as the "ubuntu" image in your example. – Florin Asăvoaie Dec 01 '15 at 13:12
  • `sudo sh mkimage-yum.sh -y /etc/yum.repos.d/epel.repo centos` works perfectly and creates a centos7 box. Now I am trying to create a specific docker box, e.g. 6.3, 6.4. I have customized the script but I am unable to create such a box. Do you know whether this is possible? Have you ever created such a box? – 030 Dec 01 '15 at 16:48
  • It is a container and not a box. Yes, just create a custom yum config that points to the repos for those versions. – Florin Asăvoaie Dec 01 '15 at 16:52
  • [I am trying to create a Docker container of a specific version of CentOS](http://serverfault.com/questions/740113/how-to-create-a-docker-container-of-a-specific-version-of-centos), – 030 Dec 01 '15 at 23:03