Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32-bit container on a 64-bit system #611

Closed
shamrin opened this issue May 15, 2013 · 36 comments
Closed

32-bit container on a 64-bit system #611

shamrin opened this issue May 15, 2013 · 36 comments

Comments

@shamrin
Copy link
Contributor

shamrin commented May 15, 2013

I understand that docker supports only amd64 for now. Does it support 32 bit containers? I want to containerize a 32-bit application with docker.

Ubuntu guide mentions that LXC supports this: lxc-create -a i386.

@jpetazzo
Copy link
Contributor

It should work, but there is a trick. When you start a container with
docker, docker will "inject" itself inside the container to perform some
extra setup. Docker is a 64 bits binary, and requires some 64 bits
libraries. So you will need to either:

  • wait until we get rid of the injection
  • compile a 32 bits docker binary
  • install some 64 bits libraries in your 32 bits container
    The last method has been confirmed to work by backjlack on the IRC channel,
    a few days ago.
    You might want to try to ask him some details. (Unfortunately I don't know
    his github nickname so I don't know how to ping him here!)

@vieux
Copy link
Contributor

vieux commented May 15, 2013

/cc @unclejack

@jpetazzo
Copy link
Contributor

Oh :-) For some reason, I thought that backjlack and unclejack were two
different persons. facepalm
Thanks Victor!

On Wed, May 15, 2013 at 7:26 AM, Victor Vieux notifications@github.comwrote:

/cc @unclejack https://github.com/unclejack


Reply to this email directly or view it on GitHubhttps://github.com//issues/611#issuecomment-17941676
.

@unclejack
Copy link
Contributor

I've had to add the following 64 bit libraries to the 32 bit image in order to get it to work with docker:

/lib/x86_64-linux-gnu/libpthread.so.0
/lib/x86_64-linux-gnu/libc.so.6
/lib64/ld-linux-x86-64.so.2

The image was working afterwards.

@dtzWill
Copy link
Contributor

dtzWill commented May 22, 2013

Hmm, wish I'd seen this earlier :). Anyway, I've had success building with a linux/386 go cross-compiler to get a 32bit docker to resolve the injection issue. Also helps to run things with 'linux32', otherwise package tools get confused.

I'd love to see (and would be happy to contribute to) first-class support for this sort of thing.

@unclejack
Copy link
Contributor

@dtzWill Would you mind sharing how you've made this work? I'm interested to know how you got docker 64bit to run docker 32bit in the container.

@dtzWill
Copy link
Contributor

dtzWill commented May 22, 2013

@unclejack sure thing. 'm not running any part of docker as 64bit, simply built docker as 32bit and disabled the amd64 check in server.go

Longer-term I'd love to see a more pervasive concept of container architecture, but my original intended short-term plan for this was:

  • Add (optional?) 'architecture' field to image description datastructure
  • Modify build system to cross-compile docker-init to various architectures (requires go cross-compilers, which are fast and easy to generate).
  • Inject appropriate docker-init into container when launching

However since simply building docker 32bit seems to work (and also works on 64bit containers I've tried so far, YMMV) I haven't pursued this.

@dtzWill
Copy link
Contributor

dtzWill commented May 22, 2013

While we're on the topic, for bonus points docker could support non-native architectures (say, ARM) using qemu-user-static, which apparently the ubuntu folks use with lxc-create [1]. I don't know how well this fits into the general goals of docker, but it might be relatively simple to implement and is something quite a few people would find rather useful. Just a thought :).

[1] https://help.ubuntu.com/12.04/serverguide/lxc.html

@shykes
Copy link
Contributor

shykes commented May 22, 2013

All of this fits in docker's goals :) Great stuff.

A good and easy first step is to add the field in the image data. Someone let me know if you want to give it a try.

Cross-compile: also a good Par to make, the build environment is itself a docker container - you can play with the dockerfile in hack/dockerbuilder.

Injecting right docker-init: is this necessary? The version running in the host and the version which will work as init should always be the same, no?

@solomonstre
@getdocker

On Wed, May 22, 2013 at 4:07 PM, Will Dietz notifications@github.com
wrote:

While we're on the topic, for bonus points docker could support non-native architectures (say, ARM) using qemu-user-static, which apparently the ubuntu folks use with lxc-create [1]. I don't know how well this fits into the general goals of docker, but it might be relatively simple to implement and is something quite a few people would find rather useful. Just a thought :).

[1] https://help.ubuntu.com/12.04/serverguide/lxc.html

Reply to this email directly or view it on GitHub:
#611 (comment)

@unclejack
Copy link
Contributor

I'll try to hack something up with qemu-user* and try to add that field.

@dtzWill
Copy link
Contributor

dtzWill commented May 24, 2013

For testing the use case described in this issue (which shouldn't require qemu), these two images I uploaded to the index might be useful:

https://index.docker.io/u/wdtz/debian-6.0-x86/
https://index.docker.io/u/wdtz/scientific-6-x86/

These execute with 32bit docker just fine, but ideally one wouldn't need a special build of docker for 32bit vs 64bit on a 64bit host.

@shykes
Copy link
Contributor

shykes commented Jul 21, 2013

This is an excellent thread, but it covers a lot of ground and is not immediately actionable so I'm closing the issue. Feel free to continue the discussion on the mailing list, or file specific improvement requests if needed.

@shykes shykes closed this as completed Jul 21, 2013
@shamrin
Copy link
Contributor Author

shamrin commented Oct 9, 2013

@dtzWill @unclejack How did you create 32-bit docker containers? I'm trying to make 32-bit debian container. I took contrib/mkimage-debian.sh and added --arch=i386 option to debootstrap. But it was not enough. The resulting docker container is stll 64-bit according to uname -m. Did you use lxc-create -a i386 to create it? If yes, then how did you import it to docker?

@jpetazzo
Copy link
Contributor

jpetazzo commented Oct 9, 2013

uname will always tell you 64 bits. Look at e.g. "file /bin/sh" to see the
real arch of the filesystem.
On Oct 9, 2013 3:03 PM, "Alexey Shamrin" notifications@github.com wrote:

@dtzWill https://github.com/dtzWill @unclejackhttps://github.com/unclejackHow did you
create 32-bit docker containers? I'm trying to make 32-bit debian
container. I took contrib/mkimage-debian.shhttps://github.com/dotcloud/docker/blob/master/contrib/mkimage-debian.shand added
--arch=i386 option to debootstrap. But it was not enough. The resulting
docker container is stll 64-bit according to uname -m. Did you use lxc-create
-a i386 to create it? If yes, then how did you import it to docker?


Reply to this email directly or view it on GitHubhttps://github.com//issues/611#issuecomment-26012959
.

@shamrin
Copy link
Contributor Author

shamrin commented Oct 9, 2013

@jpetazzo You are right, file /bin/bash says it's 32-bit. Thank you! I was confused, because I compared with traditional chroot. I have schroot with linux32 "personality", where uname -m reports "correct" architecture.

@jpetazzo
Copy link
Contributor

jpetazzo commented Oct 9, 2013

Yup, personality is different (it goes in the way to "pretend" the kernel
is 32 bits).
On Oct 9, 2013 3:21 PM, "Alexey Shamrin" notifications@github.com wrote:

@jpetazzo https://github.com/jpetazzo You are right, file /bin/bashsays it's 32-bit. Thank you! I was confused, because I compared with
traditional chroot. I have schroot with linux32 "personality", where uname
-m reports "correct" architecture.


Reply to this email directly or view it on GitHubhttps://github.com//issues/611#issuecomment-26014128
.

@ghost
Copy link

ghost commented Oct 29, 2013

Pinging for a status update on being able to create 32 bit containers. @shamrin the link to the mkimage script is broken...

@tianon
Copy link
Member

tianon commented Oct 29, 2013

That'd be because mkimage-debian.sh got renamed to mkimage-debootstrap.sh (since it works equally well for Ubuntu), and even now has an undocumented -a flag to control the arch (undocumented because docker doesn't support any other arches yet).

@shamrin
Copy link
Contributor Author

shamrin commented Oct 29, 2013

Here's the link to make it easier to find: mkimage-debootstrap.sh.
Or follow Debian/Ubuntu link in documention: Base Image Creation.

@berenddeboer
Copy link

Or use an existing 32-bit image, here's one for precise: https://index.docker.io/u/besn0847/ubuntu32/

@rorysavage77
Copy link

I have 32-Bit Fedora 20 build of Docker. The builds just completed about 10 mins ago. You will have to tweak the init scripts to launch the daemon, but it works and tested. Here, pick up a copy from my github repo: https://github.com/rcsavage/Docker-1.2.0-i686

@voidzero
Copy link

voidzero commented Oct 4, 2014

For anyone coming across this, like I have.. it's always possible to run a command in 32 bit mode. Test it, by issuing linux32 uname -a. By prepending linux32, it runs in 32 bit mode.

@isanych
Copy link

isanych commented Oct 21, 2014

How could I use linux32 command if I have 32bit container (here my question about uname on SO)?

@xnox
Copy link
Contributor

xnox commented Dec 1, 2014

Ubuntu amd64 installations enable 32-bit foreign architecture by default, however the docker containers do not appear to feature that. I guess that is a request to the official ubuntu container providers to either add 32-bit support by default and/or provide alternative images with 32-bit runtime support built-in.

@Kentoseth
Copy link

@xnox :

We have 32-bit containers here: https://github.com/docker-32bit

If you'd like to test, we could sure use any volunteers to confirm which 32-bit Ubuntu versions support Docker 32-bit (we're targeting LTS only).

@xnox
Copy link
Contributor

xnox commented Dec 2, 2014

@Kentoseth
I think you are misunderstanding my request. Or rather a feature that Ubuntu supports.

All i386 releases of ubuntu should be able support docker-32bit.

I'm asking to build: amd64 image of Ubuntu with 32-bit runtime support as part of the image, to be executed on an amd64 host, with an amd64 docker binary.

The same way that Ubuntu Desktop amd64 installations have i386 runtime support enabled which allows installation and execution of i386 packages (e.g. install hello:i386 on amd64 host to execute i386 version of hello, similarly for libraries, and even high-level apps like Skype).

@Kentoseth
Copy link

@xnox

I think I understand you now.

Unfortunately I can't help concerning that.

Hope someone else can chime in.

@ggrandes
Copy link

ggrandes commented Jan 7, 2015

@shamrin I have checked (in Ubuntu)

  • host 64 bits (docker 1.4.1) > container 32 bits > ok
  • host 64 bits (docker 1.0.1) > container 32 bits > ok
  • host 32 bits (docker 1.0.1) > container 32 bits > ok

Some 32bits images (Ubuntu 12.04 / 14.04)

docker pull ggrandes/ubuntu32
docker run -it --name="test32" ggrandes/ubuntu32 /bin/bash

@dexterddit
Copy link

Anybody tested it with 1.5?

@ggrandes
Copy link

@dexterddit yes, works.

  • host 64 bits (docker 1.5.0) > container 32 bits > ok

@dexterddit
Copy link

@ggrandes Thank you

@patrickjahns
Copy link

@Kentoseth

How can we help with 32 bit ubuntu ?
I finally got a setup running for dokku with 32 bit 14.04 ubuntu, but I had to start from bootstrap images. Id like to make this process seemingless for others. For more info on the steps ive taken so far dokku#1090

Anyone having proper buildscripts to create 32bit docker.debs ?

@ghost
Copy link

ghost commented May 4, 2018

For anyone coming across this, like I have.. it's always possible to run a command in 32 bit mode. Test it, by issuing linux32 uname -a. By prepending linux32, it runs in 32 bit mode.

@voidzero. I have read about this solution as some kind of a replacement to unprefixed uname -a. I am not sure what does it solve?

On x86_32 (docker run -it i386/ubuntu), linux32 uname -a returns:

Linux 0e0418f9b555 4.9.87-linuxkit-aufs #1 SMP Fri Mar 16 18:16:33 UTC 2018 i686 i686 i686 GNU/Linux

On x86_64 (docker run -it ubuntu), linux32 uname -a returns:

Linux c1d04cd36841 4.9.87-linuxkit-aufs #1 SMP Fri Mar 16 18:16:33 UTC 2018 i686 i686 i686 GNU/Linux

what gives?

The idea is to "distinguish" whether the OS is x86 or x64, like happens in a real VM (regardless of the host's architecture).

@isanych
Copy link

isanych commented May 4, 2018

@kasper3, I use linux32 as entrypoint in my 32bit containers. We use single installer for both 32&64 bit systems, installer check architecture and install either 32 bit or 64 bit binaries. Without linux32 installer will install 64bit binaries which would not run as there are no 64bit libs in 32bit image.

So in my use case I need both: 32bit image and linux32 as entrypoint.

@ghost
Copy link

ghost commented May 4, 2018

@isanych, copy that, makes sense. Thanks!
Would be nice to know what is the blocker of getting the real 32-bit injection in 32 bit docker as mentioned above. Who to lobby? Where to contribute? etc. to make the right thing happen.

@isanych
Copy link

isanych commented May 4, 2018

@kasper3, from my point of view 32 bit containers with linux32 trick are quite usable as is.
I'm using ivochkin/ubuntu-i386:xenial, vicamo/debian:stretch-i386, i386/alpine:3.7, redjack/centos32:5 - usually it is not difficult to find necessary base image. They are not official images, but I doubt that docker team will ever consider 32 bit as priority, it is dying arch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests