docker / cli

The Docker CLI
Apache License 2.0
4.75k stars 1.88k forks source link

docker import fails to properly set platform #5215

Closed Zopolis4 closed 1 week ago

Zopolis4 commented 1 week ago

Description

The --platform argument to docker import has no effect on the resulting OS/ARCH of the image.

Reproduce

  1. docker import https://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04.6-base-i386.tar.gz --platform linux/386 test:new
  2. docker image inspect --format='{{.Architecture}}' test:new

Expected behavior

docker image inspect --format='{{.Architecture}}' test:new should return 386, as the image platform should have been set to linux/386 by the docker import command.

docker version

Client:
 Version:           20.10.25+dfsg1
 API version:       1.41
 Go version:        go1.22.3
 Git commit:        b82b9f3
 Built:             Tue May  7 10:33:18 2024
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.25+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.22.3
  Git commit:       5df983c
  Built:            Tue May  7 10:33:18 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.24~ds1
  GitCommit:        1.6.24~ds1-2
 runc:
  Version:          1.1.12+ds1
  GitCommit:        1.1.12+ds1-2
 docker-init:
  Version:          0.19.0
  GitCommit:

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.12.0)

Server:
 Containers: 3
  Running: 1
  Paused: 0
  Stopped: 2
 Images: 26
 Server Version: 20.10.25+dfsg1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 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: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1.6.24~ds1-2
 runc version: 1.1.12+ds1-2
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.9.7-amd64
 Operating System: Debian GNU/Linux trixie/sid
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.32GiB
 Name: unbound
 ID: THJY:BEYP:XHEZ:XEMX:RIU6:URRT:CGWD:2Z7T:NPZ2:6HX3:BK6G:GTJJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: zopolis4
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

vvoland commented 1 week ago

I'm unable to reproduce the issue on the latest version:

❱ docker import https://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04.6-base-i386.tar.gz --platform linux/386 test:new
Downloading from https://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04.6-base-i386.tar.gz
sha256:42c9808ae9c694b6a26543196bb771ea8a37e698f361eef9b5fe7e3a8b1d1aa7B/42.89MB

❱ docker image inspect --format='{{.Architecture}}' test:new
386

Please note that you're running an outdated version (v20.10.25 debian package) of Docker which is EOL. Can you check if the issue persist on the currently maintained version (v27.0.3)?

I'll close the issue - if you are able to reproduce the issue on the latest version, please open a ticket in the Moby/Docker Engine issue tracker.