Create a docker image/container from EC2 AMI

I am very new to docker and am trying to import my AWS EC2 AMI into a docker image. The image is a m2 linux image.

I have also setup a private docker hub(artifactory) to which I intend to push the image and make it available for consumption. What are the steps for importing AMI into docker image without starting from a base image and updating.

  • Run VSCode in Dotnet docker container
  • How to check the configuration of Docker (volume, devicemapper, ..) after deleting many files ?
  • docker compose: create two containers from one image
  • How to delete unused docker images in swarm?
  • Can a variable be used in docker FROM?
  • Docker, Supervisord and logging - how to consolidate logs in docker logs?
  • Pointers to any explanation would work too.

  • Jelastic run.log not working on docker
  • Unable to install docker 1.5 on ubuntu 14.04 64bit
  • Numeric value not able to set as env using Dockerfile #27284
  • How to containerize InfluxDB with Docker?
  • Is it possible to link existing containers with docker?
  • Spark clustering with yarn
  • 3 Solutions collect form web for “Create a docker image/container from EC2 AMI”

    Here is how I did it.

    On source AMI locate root volume snapshot id in the description

    /dev/sda1=snap-eb79b0b1:15:true:gp2

    launch instance with public Ubuntu 14.04 AMI

    create volume from snapshot snap-eb79b0b1 (in the same region that the instance runs). attach volume to the instance as /dev/sdf

    mount volume to /mnt

    mount /dev/xvdf /mnt

    install docker

    https://docs.docker.com/engine/installation/ubuntulinux/

    import docker image from mounted root volume

    tar -c -C /mnt/ . | docker import – appcimage-master-1454216413

    docker run -t -i 6d6614111fcb03d5ca79541b8a23955202dfda74995d968b5ffb5d45c7e68da9 /bin/bash

    Docker can create create an image from a tar file using the docker import command. From the documentation:

    Usage: docker import URL|- [REPOSITORY[:TAG]]
    
    Create an empty filesystem image and import the contents of the tarball 
    (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally
    tag it.
    

    So you should be able to create a tar archive from your AMI image and then feed that to docker.

    When creating the tar file cd to the directory and tar the tree from there.

    cd /media/my-external-drive
    tar -czvf /tmp/drive-image.tgz
    

    And then to create the image …
    docker import /tmp/drive-image.tgz

    This allows the dockerized container to create the correct paths when you run it.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.