docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
751 stars 84 forks source link

experimental --platform doesn't seem to work with ubuntu #859

Open pmatos opened 4 years ago

pmatos commented 4 years ago

Ubuntu i386 image fails to run as i386 on docker.

Expected behavior

When running the image into a shell, I would expect uname -a to show me we are in a 32bit image.

Actual behavior

docker run --platform=i386 -ti ubuntu:16.04 /bin/bash
root@68de58e4123e:/# cd
root@68de58e4123e:~# uname -a
Linux 68de58e4123e 5.3.7-arch1-1-ARCH #1 SMP PREEMPT Fri Oct 18 00:17:03 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce the behavior

See above.

Output of docker version:

Docker version 19.03.4-ce, build 9013bf583a

Output of docker info:

Client:
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.3.1)

Server:
 Containers: 263
  Running: 0
  Paused: 0
  Stopped: 263
 Images: 329
 Server Version: 19.03.4-ce
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d50db0a42053864a270f648048f9a8b4f24eced3.m
 runc version: d736ef14f0288d6993a1845745d6756cfc9ddd5a
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.3.7-arch1-1-ARCH
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 62.72GiB
 Name: andromeda
 ID: TGIQ:AXCV:IFQT:7MER:7RLW:NVPL:UU6Y:2HKS:NVXW:O4OH:2FGP:HT3Z
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: pmatos
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.)

Physical x86_64 running ArchLinux.

cpuguy83 commented 4 years ago

"uname" is coming from the kernel not from the userspace programs. A simple-ish way to check is to apt-get update, you should see i386 package repos listed.

I did notice, however, that --platform only seems to apply if the with the given tag needs to be pulled, it doesn't seem like the real image sha is resolved per platform if the tag already exists.

kolyshkin commented 4 years ago

Well, I think that setarch i386 can be used:

$ docker run --platform=i386 -ti ubuntu:16.04 /bin/bash
root@3a80cb4c4eae:/# uname -a
Linux 3a80cb4c4eae 4.19.79+ #92 SMP Mon Oct 14 11:37:29 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux
root@3a80cb4c4eae:/# setarch i386
# uname -a
Linux 3a80cb4c4eae 4.19.79+ #92 SMP Mon Oct 14 11:37:29 PDT 2019 i686 i686 i686 GNU/Linux
# 

In general, I think the problem is, the --platform is only for creating the container, not for running it (otherwise we could do personality() syscall).