Create base docker centos image with python 2.7.8
Question: I've found [this](http://drewcdecker.me/2014/10/creating-a-centos-65-base-
docker-image/) which walks you through creating a base bare-metal centos
image. I want to however install some additional yum packages, download Python
2.7.8 and build it.

I had this in a dockerfile and already working like:

    
    
    # Set the base image to Ubuntu
    FROM centos:7
    
    # File Author / Maintainer
    MAINTAINER Sam Mohamed
    
    # Update the sources list
    RUN yum -y update
    RUN yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel xz-libs gcc g++ build-essential make
    
    # Install Python 2.7.8
    RUN curl -o /root/Python-2.7.9.tar.xz  https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
    RUN tar -xf /root/Python-2.7.9.tar.xz -C /root
    RUN cd /root/Python-2.7.9 && ./configure --prefix=/usr/local && make && make altinstall
    
    # Copy the application folder inside the container
    ADD `pwd` /opt/iws_project
    
    # Download Setuptools and install pip and virtualenv
    RUN wget https://bootstrap.pypa.io/ez_setup.py -O - | /usr/local/bin/python2.7
    RUN /usr/local/bin/easy_install-2.7 pip
    RUN /usr/local/bin/pip2.7 install virtualenv
    
    # Create virtualenv and install requirements:
    RUN /usr/local/bin/virtualenv /opt/iws_project/venv && source /opt/iws_project/bin/activate && pip install -r /opt/iws_project/requirements.txt
    

How can I convert the above into a base image?


Answer: You are probably better off building the given Dockerfile and using the
resulting image as the base for future images. This is much easier to maintain
and doesn't really cost anything in terms of resource use.

But if you really want to create a single-layer "base image", the steps are as
follows:

  1. Install everything you want into some directory (`docker-centos-65/` in the linked tutorial).

     * You can modify the `febootstrap` command from the tutorial you linked to install additional `yum` packages by specifying more `-i` flags.
     * You can perform any other custom installs (e.g. Python) manually, just make sure everything ends up in the same root directory
  2. Create a `tar` archive of the directory where everything is installed, and pipe this to the [`docker import`](https://docs.docker.com/reference/commandline/import/) command:
    
        tar c -C docker-centos-65/ . | docker import - my-base-image
    

