daydreamer
daydreamer

Reputation: 91949

Docker 32-bit Image downloaded, but tells its a 64-bit architecture

I might be entirely wrong here but, I pulled 32bit/ubuntu from docker registry and wen I run uname -a I get x86_64

➜  ~  docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
erlang-build-box         latest              fd61e832201b        7 weeks ago         1.841 GB
hello-world              latest              e45a5af57b00        9 weeks ago         910 B
32bit/ubuntu             14.04               6de534a1b6e3        4 months ago        290.7 MB
phusion/passenger-full   0.9.10              29eb0419ab6f        10 months ago       649.3 MB
➜  ~  docker run -t -i 6de534a1b6e3 /bin/bash
root@c40d7c09be96:/# uname -a 
Linux c40d7c09be96 3.16.7-tinycore64 #1 SMP Tue Dec 16 23:03:39 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
root@c40d7c09be96:/# uname -m
x86_64
root@c40d7c09be96:/# 

Am I wrong in my understanding that this machine is 64bit?

Upvotes: 6

Views: 6244

Answers (4)

ncoghlan
ncoghlan

Reputation: 41486

Some specific code examples for cases where you only need to distinguish between running in i686 and x86_64 docker containers and don't need to handle other architectures.

Instead of checking the kernel type as follows:

if [ "$(uname -m)" = "x86-64" ]; then
  ... 64-bit code ...
else
  ... 32-bit code ...
fi

The system binary build type can be checked with:

if [ "$(file -bL /bin/sh | cut -f 2 -d ' ')" = "64-bit" ]; then
  ... 64-bit code ...
else
  ... 32-bit code ...
fi

Upvotes: 1

Rastersoft
Rastersoft

Reputation: 114

Just a note: systemd-nspawn can "virtualize" the processor mode, and trick the processes inside to believe it is a 32-bit processor (tested by me). AFAIK, LXC can too.

And I mean that running "uname -m" returns "i686" (and my host OS is running in 64 bit mode)

Upvotes: 0

user2915097
user2915097

Reputation: 32156

extract from https://github.com/docker/docker/issues/611

uname will always tell you 64 bits. Look at e.g. "file /bin/sh" to see the real arch of the filesystem.

Upvotes: 2

Adrian Mouat
Adrian Mouat

Reputation: 46470

Docker containers always use the kernel from the host. You have a 64bit host, so that's what it's reporting.

The container image is 32-bit in the sense that all the binaries are 32-bit and could be processed by a 32-bit architecture.

Docker does not do virtualisation.

Upvotes: 7

Related Questions