How to install 32-bit docker container - docker

I'm trying to create a 32-bit docker image with Ubuntu 14.04 and, any time that I run uname, I see that it is x86_64 instead of i386. Could anyone tell me why this is happening?
docker run talex5/lucid32 uname -m
The weird thing is when I look up the architecture type a different way, it says 32-bit:
docker run i386/ubuntu:14.04 file /sbin/init
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=c394677bccc720a3bb4f4c42a48e008ff33e39b1, stripped`
This happens consistently whenever I download different docker images that say they are 32-bit and even when I create my own docker image using debootstrap.
Thanks!

uname reports the version and OS details of the kernel, but Docker containers always use the host system's kernel, and if it's a 64-bit kernel it will report x86_64.
You should see the same results running this with a mixed 32-/64-bit OS install (in Ubuntu land installing packages like libc6:i686); with a 32-bit filesystem tree in a chroot; and in a Docker container; which are all the same case of running 32-bit binaries on a system with a 64-bit kernel.

This is possible these days, with just a simple script. You could use https://github.com/docker-32bit/ubuntu.

Related

Docker container CPU features do not match the host's ones (RDTSCP)

I am using a Docker container to run a C++ compiled executable. The Docker container is built using the latest Linux Debian distribution, while the host is a MacOS system (MacOS 12.6, on MacBook Pro 16 Latest 2019).
Within the C++ code, I call the function __rdtscp(unsigned int *__A) including x86intrin.h for monitoring purpose. Compiling and executing the application on the MacOS host it works correctly. But if I try to run it within the Docker container, I obtain a Illegal instruction error (it is compiled on another physical Linux host, I need this: anyway, I can run the same executable on different Linux machines and also on the container generated by the same Docker image I use if executed on another host).
Looking deeper into the issue, I found that __rdtscp(unsigned int *__A) must be supported by the CPU. It should be supported by all the CPUs after 2010/2011. In fact, it seems that flag is reported within the host CPU's features (RDTSCP). The problem is that I cannot find it within the container CPU's features.
Note that using __rdtsc() it works correctly, but this is not serializable, so I want to use __rdtscp(unsigned int *__A).
Following the MacOS host output of sysctl -a | grep machdep.cpu
And this is the output of the Debian docker container of lscpu
Could you help me to figure out the reason of this difference? Is there a way to force Docker to provide the same host CPU's features?
Thank you!

How do I build a Docker image for an ARM device?

I'm noticing exec user process caused "exec format error" when trying to run a Docker image on a Raspberry Pi 4.
First I'm bewildered that a Docker image is pulled that won't run on the platform to begin with. Nonetheless I am keen to make it work, but I don't know how.
Here's the project: https://github.com/kaihendry/sla How can I build ARM compatible images?
The FROM golang line will pull the appropriate architecture; they have arm v6 (older pi / pi 0 running raspbian) + arm v7 (newer pi running raspbian) and arm64 (newer pi running ubuntu) as part of a multi-arch docker image https://hub.docker.com/_/golang?tab=tags
Your problem with exec format error (i.e. it is the wrong binary format) appears to just be the line https://github.com/kaihendry/sla/blob/a22d983340f3df794696e5c8e31cf3b89f7edd89/Dockerfile#L14 where your architecture is wrong for a pi; it should be GOARCH=arm (32 bit, non-ubuntu) or GOARCH=arm64 (ubuntu), additionally for 32 bit ARM (v6 and v7) you would also need to specify GOARM=6 or GOARM=7 per https://github.com/golang/go/wiki/GoArm
I have tested your code with a swap to to GOARCH=arm64 (and no GOARM required) and had it build and run on my pi3b+ running ubuntu.
Noting for future reference I suspect my answer may change if/when raspbian switches to 64 bit.

How did Docker know to emulate arm architecture?

This was a huge surprise for me:
Today, using Docker For Mac (18.03.1-ce-mac65), I ran a Debian Stretch image. Inside the image I mounted the latest Raspbian Stretch image (2018-04-18-raspbian-stretch-lite) using mount. I then used chroot to this mounted Raspbian filesystem.
This is where it got weird. I was able to use apt (without any special modifications) to install software into this mounted filesystem.
Running:
dpkg --print-architecture
returned: armfh
and the software I installed (vim) worked like a charm
I was even able to compile a simple program using gcc and run it.
But, I need to know! How is this possible?
According to Docker:
Docker for Mac provides binfmt_misc multi architecture support, so you can run containers for different Linux architectures, such as arm, mips, ppc64le, and even s390x.
EDIT
On Linux, you can install qemu-user-static and then follow this git repo to get cross-architecture support!

Installing and using docker on 32 bit machine

I know that the official support is only for 64-bit but I can see from a few people have tried to custom build the docker binaries for 32-bit and succeeded (32-bit version of docker maybe a little unstable but it is fine for my use-case).
However, most of those blogs are old and do not work. Is there anyone who has done this recently?
I'm trying to build docker on 2 machines (i686) running with debian - wheezy and stretch (with kernel > 3.10; the minimum required). Has at-least 2GB of RAM and sufficient disk space.
There's 32bit docker on 32bit ARM machines, i think i've seen it done on RPis and ODROIDs at least.
On 32bit x86... i doubt you'll find much. It's not that it's impossible (if there's 32bit ARM docker, there can be 32bit x86 docker), but nobody cares enough. You can run 32bit docker images (in fact i've done it recently) on a 64bit system, but docker itself...

Windows Image on Docker

How can I create an image in Docker with Windows as the base OS.
For instance; the 'FROM' command in a Dockerfile is used to load the base OS kernel. Eg: 'FROM ubuntu'(ubuntu kernel in this case).
Is there a way in which I can run a command like 'FROM windows7'.
I need it to setup image for build purpose, since I need to run Microsoft compiler 'cl' ; which runs only on windows.
So the dockerfile will look something like:
FROM windows7
RUN install cl
...
Not yet!
Docker depends on the sharing of an linux kernel.
In the moment Microsoft and Docker are working on a Windows version, sharing the windows kernel. This is already working! But only for windows 10 insider build. Where a special linux kernel like micro windows is included, which is then the base for the windows container.
A
FROM windows7
will never exist. Depending on the architecture of windows7.

Resources