Background story is simple: I've got x86 Windows7, and wanted to run docker. Docker-for-Windows says it needs Windows10Pro or better due to its improved Hyper-V support. Eh. Fortunatelly, they provide so-called "Docker Toolbox" for other systems that does not match requirements for normal installation. Docker Toolbox is essentially a VirtualBox setup that will host a VM inside which Docker will be able to set itself up. Alright! I tried. Guess what! Docker Toolbox needs 64bits.
I couldn't understand why it's not available on x86, it sets up a goddamn VM, and VirtualBox works on 32bit as well! I searched a bit and I found out that there were some recent patches and updates to enable running boot2docker image on 32bit. I think Stefan Scherer developed a patch allowing that. It was ~1 year ago, so I searched for some instructions how to apply that. I think my start point in that matter was this article and some further articles indicated there. Their story was simple: everything works, you just need to prepare manually the initial VM, you get rest from chocolatey repository.
Unfortunatelly, these articles are a bit outdated and it turns out that today there's much more work to do than was described. Installing docker-machine via choco fortunatelly indeed worked fine! However, when I wanted to install current stable Docker version 17.06 on my x86 machine - Guess what! - since version 17.06 they stopped providing x86 builds, and more, they seem to have removed old x86 builds as well (only x86_64 in https://download.docker.com/win/static/ subfolders). Hi Murphy!
But, since you are here, you're probably interested in how to get them back. Skip to the end of this text for a link to binaries, but be warned that at the time of reading this, they may be old, and I probably won't be rebuilding and updating any time soon.
Setup tools and freebies
Off we go then:
- Install VirtualBox (https://www.virtualbox.org/wiki/Downloads)
- Install chocolatey (https://chocolatey.org/install)
- Install docker-machine via choco (
choco install docker-machine
) - Create a default VM through docker-machine (
docker-machine create --driver virtualbox default
) - Check if the VM works (
docker-machine status default
) - Check if you can get the config (
docker-machine env default
) - Store the config for later (
docker-machine env default > env.bat
)
If docker-machine does not work for you, panic. Maybe you will need to build it yourself as I did with docker-cli and docker-compose. I didn't have to, so I don't have a solution/instruction for that, sorry.
Rest of the article assumes that docker-machine still supports x86 hosts and that installing docker-machine succeeded.
- Try installing docker (
choco install docker
) - Try installing docker-compose (
choco install docker-compose
) - Check if it works (
docker version
) - Check if it works (
docker-compose version
)
Most probably, last two points will fail with "program is not valid win32 application" error or similar. This means that choco has found only x86_64 version and installed that for you, and, well, it's unusable. Uninstall them by
choco uninstall docker
choco uninstall docker-compose
Btw: If you don't need the latest version of docker, you can try installing some older one. I found out that 17.05 runs fine under Windows7 32bit - you can get it by choco install docker --version 17.05
. However, at the time of writing, you won't get docker-compose that way, since they only provide x64 binaries. If you found yourself an acceptable and working version of docker, skip the next chapter and fast-forward to buiding docker-compose.
Building docker-cli for x86
Let's get the basic docker commandline utilities, the "docker-cli" project. For that, we have a small chicken-and-egg problem, since the build process actually required a working docker installation. However, we already do have a docker-machine up and running, and that's exactly what's neeed.
But first, we need to get inside it. If you ran VirtualBox GUI, you will be able to simply show the VM's screen and use it directly as a terminal. However, I don't recommend it. Clipboard will not work, for example. I prefer to use SSH, any client will work, I like PuTTY. Peek the env.bat
from point (7) and check the IP address of the VM and connect to it through SSH. At the time of writing, the default login:pass is docker:tcuser. Watch out - while default VM's screen from VirtualBox, which logs you in as root
- the SSH will log you in as docker
. Some commands may require elevation, but you can even sudo sh
and be root
..
Once you have access to the terminal, check if it really came with some default tools and also check if the network access works.
docker version
git --version
ping www.google.com
If anything of those does not work, you will have to fix that somehow to continue.
Assuming everything's good, fetch the sources:
cd /root
git clone https://github.com/docker/cli.git
cd /root/cli
and do not build it yet, you would just waste your time.
At the moment of writing, the default scripts will build you linux, osx, or windows version, but the windows part is configured to x64, so it needs a few updates.
At some point of time I found this articles, which gave me a great kick-off in that matter:
- this article "Docker Daemon for x32 architectures"
- or that article "Installing the Docker Client CLI on 32-bit Windows" (it's from 1st April, but no fools there)
- https://gist.github.com/prateekgogia/05f058bafbccc2478fcc/2f6c7b632a7b391618a3ad6cfdce949142efa3c2
I think I got that last link it from first article, and then followed GIST updates. Anyways, it was supposed to replace the default 'Dockerfile', however.. if I remember well, the build scripts have changed since it was last posted, and I'm pretty sure that eventually I didn't use it at all. I don't remember, and I can't retry this right now. I mention it there only because these articles were important and because it may be needed for someone in case I screwed up this instruction.
When I noticed that I cannot use that Dockerfile from prateekgogia's GIST, I looked around and noticed that docker-cli is written in GO-LANG. I thought that this one should have not a single problems cross-compiling for win32 so I just changed the build scripts to target different platform:
cd scripts/build
- edit the file called
windows
At this moment you will probably notice that there's no software.. unless you want to cat/sed, let's install some. It's not debian/ubuntu/redhat/etc, we're on TinyCoreLinux, package management fortunatelly exists, but repo is limited. I found two editors capable of working in terminal:
tce-load -wi nano
tce-load -wi vim
One is enough, pick what you like the most or dislike the least.
Once you have editor, edit file called "windows" and change BOTH:
CC=
fromx86_64-w64-mingw32-gcc
toi686-w64-mingw32
GOARCH=
fromamd64
to386
Remember to save that file.
In case you noticed 'w64' in the mingw package name, it's OK. That version can build both x64 and x86 binaries.
Now, try building the cross-compiled profile:
cd ../..
(so you're back in 'cli' folder)make -f docker.Makefile cross
The line (23) is taken from readme available at docker-cli's github page. If something goes very wrong, maybe it has changed since I wrote this text. Just go there and check what's the current startup line, maybe you will even find better instruction than mine here.
Anyways, this line will, again, most probably, fail due to make
command not being present. Just install it in a similar way to installing text editor:
tce-load -wi make
and retry line (23).
It will take some time. Build process will download mingw, download and run some containers for the actual build process, and so on. After it built everything, it may end up with crash on copying the final output .EXE file. I might have mixed the facts with how building docker-compile worked, so I'm not sure if it happens at all, but if it does, just check the 'dist' folder for .EXE file. If it has some x64 or amd64 in the filename, don't believe that file name - we changed target architecture in build scripts, and that file name may simply be wrong.
- Copy that file to your win32 host machine to some folder of your choice
- Rename to
docker.exe
- Try running i.e. typical
docker version
to check if it works. - Add location of that file to PATH environment variable
Since you have now both docker-machine
and docker
commands available, you may use now them to clean up the containers and images that were used by the build process. That's optional, you can leave them there if you plan to do more builds in future.
I suppose you also may ignore the root docker container that you used as the entry-point terminal to download the sources and edit configuration files. That container seems to be automatically purged and cleaned at every (re)start of the docker-machine.
Btw. If docker
complains about missing settings, use env.bat
file to set them. It may be a good idea to refresh that file at times, see line (7).
Building docker-cli for x86
It turns out that docker-compose is written in Python not in GO, and that at the time of writing this text, Python tools that build .EXE files lack support for cross-compiling between x64 and x86 (or I may have just failed to find how to do it - however many articles claim that this option in PyInstaller was recently removed). If you want to get x32 executable, you have to run the build process on x86 machine. I suppose we already have one: your host machine that you want to run docker on.
git clone https://github.com/docker/compose.git
- view
script/build/windows.ps1
and follow the procedure stated in the opening comment - Install Python 2.7.x if you don't have it yet (https://www.python.org/downloads/)
- Ensure that
python
andpip
are both at PATH (if not, add something like "C:\Python27;C:\Python27\Scripts" to the PATH) pip install virtualenv
powershell Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
cd compose
(the root folder of the sources)powershell -file .\script\build\windows.ps1
Again, it may take a while to build. It's all in Python and it uses PyInstaller to generate .EXE file, and it is smart enough to notice that your current OS is 32bit and will build you a 32bit executable. Again, it may fail at the very end, during file-copying. If it does, look for a new .EXE file that should show up in the dist
folder. Probably, it's name is docker-compose-Windows-x86.exe
and that's the problem, because build process is hardcoded to copy docker-compose-Windows-x86_64.exe
(last lines of the .ps1 file). Anyways, we don't care. We got out .EXE file.
- Copy that file to some folder of your choice
- Rename to
docker-compose.exe
- Try running i.e. typical
docker-compose version
to check if it works. - Add location of that file to PATH environment variable
Now, optionally, you can delete the folder with docker-compose sources, and uninstall Python27, and remove Python and Python\Scripts from PATH.
Disclaimer
As usual, there may be some minor gaps and noise in the process I described above, I wrote this instruction basing on my notes gathered through the last few days. I made many consecutive attempts before achieving the goal of having x86 versions of docker-machine, docker-cli and docker-compose, so I might have forgotten/overlooked/mixed up some facts, like forgetting about tce-load -wi
something extra. However, I'm sure that overall process looked like I described above, and I got it working. I managed to run hello-world container, ubuntu container, and ubuntu32 container, and manage them, so.. seems to work.
TL;DR
I built them, so you can get them here:
Please be aware that those builds were done directly from the main git repos, so they are DEV/EDGE builds, not STABLE builds. Since the version numbers are not frozen (and i.e. docker-cli
got already some new commits for 17.07 so if yo do your build of 17.07 you'll get a newer 17.07 than my 17.07), I included a timestamp and GIT SHA at the end of the filenames so we can later identify what's the exact source code version. Both tools also seem to identify themselves via version
command, including commit hash.
Update: ~5yrs passed, I removed those builds from file hosting. They were probably criminally outdated already anyways. If you relied on them in any way, sorry, deleted permanently.