How and Why?
Let’s say you have a server that has been lovingly hand-crafted that you want to containerize.
Figuring out exactly what software is required on there and what config files need adjustment would be quite a task, but fortunately blueprint exists as a solution to that.
What I’ve done here is automate that process down to a few simple steps. Here’s how it works:
You kick off a ShutIt script (as root) that automates the bash interactions required to get a blueprint copy of your server, then this in turn kicks off another ShutIt script which creates a Docker container that provisions the container with the right stuff, then commits it. Got it? Don’t worry, it’s automated and only a few lines of bash.
There are therefore 3 main steps to getting into your container:
– Install ShutIt on the server
– Run the ‘copyserver’ ShutIt script
– Run your copyserver Docker image as a container
Install ShutIt as root:
sudo su - pip install shutit
The pre-requisites are python-pip, git and docker. The exact names of these in your package manager may vary slightly (eg docker-io or docker.io) depending on your distro.
You may need to make sure the docker server is running too, eg with ‘systemctl start docker’ or ‘service docker start’.
Check out the copyserver script:
git clone https://github.com/ianmiell/shutit_copyserver.git
Run the copy_server script:
cd shutit_copyserver/bin ./copy_server.sh
There is a prompt to ask what docker base image you want to use.
Make sure you use one as close to the original server as possible, eg ubuntu/trusty or ubuntu:14.04 rather than just ‘ubuntu’.
Run the built image:
docker run -ti copyserver /bin/bash
You are now in a practical facsimile of your server within a docker container!
If it doesn’t work, here’s a checklist of things that might have gone wrong:
- Python 2.7+ is required
- Using the wrong image – make sure it’s as close to the original as possible
- Not having Docker installed on the host
- The server is not apt or yum based
- The server may run out of memory (at least 1G recommended)
If none of the above work, send the output of:
./copy_server.sh -l debug --echo cd /tmp/shutit_copyserver && shutit build --echo -d docker -s repository tag yes -s repository_name copyserver -l DEBUG
to an issue on github.
My book on Docker:
Get 39% off with the code: 39miell
Buying the print or ebook editions will get you ebook updates as they are published.