docker / roadmap

Welcome to the Public Roadmap for All Things Docker! We welcome your ideas.
https://github.com/orgs/docker/projects/51
Creative Commons Zero v1.0 Universal
1.74k stars 257 forks source link

[Docker Desktop for Mac] - Support for running x86-64 binaries with Rosetta 2 #384

Open christophermclellan opened 2 years ago

christophermclellan commented 2 years ago

Tell us about your request Support Rosetta 2 for running x86-64 Linux binaries on Apple Silicon

Which service(s) is this request for? Docker Desktop for Mac

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? Ensure that users can run their Intel-based workloads on Apple Silicon, using Rosetta 2

Are you currently working around the issue? Docker Desktop users can currently use QEMU for this

thisisthekap commented 2 years ago

@christophermclellan With this feature, we should be able to use Microsoft SQL server for Linux on M1. This would be awesome!

darrinholst commented 2 years ago

we should be able to use Microsoft SQL server for Linux on M1

If this is true you're going to make many long-suffering mssql users very happy. Very much looking forward to this.

Due to the presumed qemu "issue" there is actually no workaround for running that image on arm64. (yes, I know about colima. no, it's not a viable workaround)

thisisthekap commented 2 years ago

@christophermclellan Are you able to provide some more detail on the plans for implementing this feature?

arsereg commented 2 years ago

@christophermclellan This would allow us to use Java Temurin images. Currently, they have been investing lots of time figuring out how to build images for m1, and it doesn't seem this will be solved anytime soon.

Multiple other services would work amazingly, like Payara or MSSQL

boboldehampsink commented 2 years ago

Another use case for running Intel on Rosetta 2 over a native amd64 image is because of dev/prod parity with the server for example - see https://github.com/heroku/stack-images/issues/194

thisisthekap commented 2 years ago

@christophermclellan Are you able to provide a timeline describing when this feature is going to be implemented?

diogonborges commented 2 years ago

Any development here? Ball-park timeline for this?

konstantinos-kafkas-cko commented 2 years ago

Please add support for Apple M1 silicon.

christophermclellan commented 2 years ago

Hi folks, please excuse my delay regarding timelines. So, right now we are focussing on getting virtiofs implemented as the default file sharing mechanism on Mac, we're very close on this one. Once complete, we'll immediately turn attention to Rosetta. I'm not able to disclose precise timelines, but...soon !

joostvanvucht commented 2 years ago

rosetta seems to works quite well, tested using ventura, utm 4.04 beta & manual docker setup on macbook m1 air

root@ub1:~# uname -a Linux ub1 5.15.0-47-generic #51-Ubuntu SMP Fri Aug 12 08:18:32 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

root@ub1:~# mount | grep rose rosetta on /mnt/rosetta type virtiofs (rw,relatime)

root@ub1:~# ps -ef | grep rose 2001 5803 2728 1 14:28 ? 00:00:42 /mnt/rosetta/rosetta /opt/tibco/ftl/6.6/bin/tibftlserver -c /config/ftl.yaml -n ftlserver-0 2001 5882 5803 3 14:28 ? 00:01:32 /mnt/rosetta/rosetta /opt/tibco/ftl/6.6/bin/tibmux --realmserver http://127.0.0.1:30080 --client-label ftl.ftlserver-0 --external-address ftlserver-0@ftlserver-0.ftlservers:30080 --bind-address *:30080 --peer-muxes ftlserver-0@ftlserver-0.ftlservers:30080 --trace warn 2001 5983 5803 42 14:28 ? 00:18:50 /mnt/rosetta/rosetta /opt/tibco/ftl/6.6/bin/tibrserver --server.label realm.ftlserver-0 --data /data/ftlserver_0_data --http 127.0.0.1:0 --ftl ftlserver-0.ftlservers:30083 --gui 127.0.0.1:0 --client.url http://127.0.0.1:30080 --ftlserver.urls ftlserver-0@ftlserver-0.ftlservers:30080 --ftlserver.name ftlserver-0 1001 6187 4686 2 14:28 ? 00:00:56 /mnt/rosetta/rosetta /etc/alternatives/jre/bin/java -javaagent:/jmx_prometheus_javaagent-0.16.1.jar=8080:/opt/config/config.yaml -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/activemq/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/apache-activemq-5.15.2//tmp -Dactivemq.classpath=/opt/apache-activemq-5.15.2//conf:/opt/apache-activemq-5.15.2//../lib/: -Dactivemq.home=/opt/apache-activemq-5.15.2/ -Dactivemq.base=/opt/apache-activemq-5.15.2/ -Dactivemq.conf=/opt/apache-activemq-5.15.2//conf -Dactivemq.data=/opt/apache-activemq-5.15.2//data -jar /opt/apache-activemq-5.15.2//bin/activemq.jar start 2001 6337 5803 2 14:28 ? 00:01:08 /mnt/rosetta/rosetta /opt/tibco/ftl/6.6/bin/tibpserver --name default_ftlserver-0 --data /data/ftlserver_0_data --realmserver http://127.0.0.1:30080 2001 6377 4463 3 14:28 ? 00:01:36 /mnt/rosetta/rosetta /opt/tibco/as/4.7/bin/tibdgkeeper -r http://ftlserver-0.ftlservers:30080 -n keeper-0 -g VirtueleTreinInfoStore 2001 6419 2486 5 14:28 ? 00:02:31 /mnt/rosetta/rosetta /opt/tibco/as/4.7/bin/tibdgproxy -r http://ftlserver-0.ftlservers:30080 -n proxy-0 -g VirtueleTreinInfoStore 2001 6421 3376 0 14:28 ? 00:00:09 /mnt/rosetta/rosetta /opt/tibco/as/4.7/bin/tibdgadmind -r http://ftlserver-0.ftlservers:30080 -l :30081 2001 6734 4895 3 14:28 ? 00:01:24 /mnt/rosetta/rosetta /opt/tibco/as/4.7/bin/tibdgnode -r http://ftlserver-0.ftlservers:30080 -n cs-01-node-0 -g VirtueleTreinInfoStore joost 7107 3827 0 14:28 ? 00:00:19 /mnt/rosetta/rosetta /opt/tibco/ems/8.6/bin/tibemsd -config /shared/ems/config/emsserver-svc.json root 7141 3827 0 14:28 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/sh /runPromCollector.sh root 7159 7141 0 14:28 ? 00:00:18 /mnt/rosetta/rosetta /usr/bin/java -cp emsStatsLogger.jar:/ems/lib/tibjmsadmin.jar:/ems/lib/jms-2.0.jar:/ems/lib/tibjms.jar EmsStatsPromCollector -config /config/servers.xml -interval 60 -job TIB-EMS-vtlocal -debug -nolog 48 9352 9190 0 14:31 ? 00:00:00 /mnt/rosetta/rosetta /bin/bash /treinviewer/scripts/run.sh root 9368 9352 0 14:31 ? 00:00:00 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND 48 9369 9368 0 14:31 ? 00:00:00 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND 48 9370 9368 0 14:31 ? 00:00:02 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND 48 9371 9368 0 14:31 ? 00:00:02 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND 48 9372 9368 0 14:31 ? 00:00:02 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND 48 10480 9368 0 14:35 ? 00:00:03 /mnt/rosetta/rosetta /usr/sbin/httpd -D FOREGROUND root 13340 13162 0 14:38 ? 00:00:01 /mnt/rosetta/rosetta /usr/bin/sh /wait-for-service.sh root 17114 16961 0 14:47 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/sh /wait-for-service.sh root 17357 17159 0 14:47 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/sh /wait-for-service.sh root 17374 17193 0 14:47 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/sh /wait-for-service.sh 2001 21600 20248 12 14:58 ? 00:01:54 /mnt/rosetta/rosetta /opt/tibco/be/6.0/bin/be-engine --propFile /opt/tibco/be/6.0/bin/be-engine.tra --propVar AS_DISCOVER_URL=tcp://masterdataengine-74c44cd5c7-rg8bx:50000 --propVar AS_LISTEN_URL=tcp://masterdataengine-74c44cd5c7-rg8bx:50000 --propVar jmx_port=5555 -n VTMasterDataEngine -c /opt/tibco/be/application/MasterData.cdd -u VTMasterDataEngine -p beprops_all.props /opt/tibco/be/application/ear/be_masterdata-1.66.0.ear --innerProcess 472 25099 24317 0 15:04 ? 00:00:04 /mnt/rosetta/rosetta /usr/share/grafana/bin/grafana-server --homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini --packaging=docker cfg:default.log.mode=console cfg:default.paths.data=/var/lib/grafana cfg:default.paths.logs=/var/log/grafana cfg:default.paths.plugins=/var/lib/grafana/plugins cfg:default.paths.provisioning=/etc/grafana/provisioning root 28779 13340 1 15:12 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/nc -z cacheenginediscoverynode-svc 50000 root 28780 17114 1 15:12 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/nc -z cacheengine-svc 50000 root 28781 17374 1 15:12 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/nc -z cacheengine-svc 50000 root 28783 17357 1 15:12 ? 00:00:00 /mnt/rosetta/rosetta /usr/bin/nc -z cacheengine-svc 50000 root 28785 23820 0 15:12 pts/2 00:00:00 grep --color=auto rose

ianjukes commented 2 years ago

Hi folks, please excuse my delay regarding timelines. So, right now we are focussing on getting virtiofs implemented as the default file sharing mechanism on Mac, we're very close on this one. Once complete, we'll immediately turn attention to Rosetta. I'm not able to disclose precise timelines, but...soon !

Thank you @christophermclellan!

JoeZhongTR commented 1 year ago

I need to dev/run python on a x86_64 docker on M1 Macs. Looking forward to it!

toxik commented 1 year ago

Hi folks, please excuse my delay regarding timelines. So, right now we are focussing on getting virtiofs implemented as the default file sharing mechanism on Mac, we're very close on this one. Once complete, we'll immediately turn attention to Rosetta. I'm not able to disclose precise timelines, but...soon !

Heya, any news? 😄

dansitu commented 1 year ago

This will be a game changer for our team, thank you for your hard work!

Will-Bill commented 1 year ago

MS SQL on Mac M1 is requested a lot, I think this would solve that issue too.

kirbyzhou commented 1 year ago

Is there any beta version can try it?

wowditi commented 1 year ago

If it helps anyone, when running a fedora 36 VM using UTM with rosetta mounted to /media/rosetta/rosetta the following command allowed docker to use it for x86_64 images

echo ':rosetta-x86_64:M:0:\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/media/rosetta/rosetta:CF' > /proc/sys/fs/binfmt_misc/register

thisisthekap commented 1 year ago

@wowditi Sounds awesome! Are you able to provide some more detail on how to setup & use docker in this scenario?

wowditi commented 1 year ago

@thisisthekap start an aarch64 fedora 36 VM (https://getfedora.org/en/workstation/download/) using UTM and enable "Use Apple Virtualization" and "Enable Rosetta". Once the installation is complete install docker according to the instructions (https://docs.docker.com/engine/install/fedora/). Then mount the Rosetta binary as described by the UTM documentation https://docs.getutm.app/advanced/rosetta/. Fedora does not include an "/usr/sbin/update-binfmts" script so instead of that you need to use the above command. Then you should be able to start docker x86_64 images and you can check using "ps" that every command is started with /media/rosetta/rosetta and that the performance is a lot better than qemu-user-static (which is what docker desktop uses).

I tried to get it to work in docker desktop using a simple mount, but I think the problem is that the VM needs to run in a special memory mode which I could not figure out how to do unfortunately.

thisisthekap commented 1 year ago

@wowditi Concerning using the new vm in a transparent way: Would the creation of a separate docker context be feasible, that might be optionally set to be the default one? (https://docs.docker.com/engine/context/working-with-contexts/)?

wowditi commented 1 year ago

@thisisthekap You could do that, but I've simply been using docker in the VM itself. Do realise that in order to mount from the Mac filesystem you would first have to mount it to the VM which is quite a bit slower than using the filesystem in the VM itself (this is also how Docker desktop does it, only they do it a bit more transparently).

thisisthekap commented 1 year ago

No, I do not want do do any mounts. I just want to use it as docker machine for my local docker cli on my mac.

wowditi commented 1 year ago

Then it works. First expose the port of the VM, such as https://gist.github.com/styblope/dc55e0ad2a9848f2cc3307d4819d819f describes. Then create a new docker context e.g. (the ip must be that of the vm): docker context create vm --docker "host=tcp://192.168.2.41:2375" And then you can do: docker -c vm run -it -p 80:80 strm/helloworld-http You can then in the browser go to the ip address of the VM and should see the hello world page

dictcp commented 1 year ago

lima-vm recently implemented Rosetta support in the latest development branch. It allows you run amd64 container on Apple silicon, via Rosetta, with less overhead compared to qemu.

https://github.com/lima-vm/lima/releases/tag/v0.14.0-beta.1

For people who are interested in rosseta support may try this.

thisisthekap commented 1 year ago

@dictcp Did you get docker working using the lima beta?

JackEllis commented 1 year ago

@dictcp +1 on that too, I can't even figure out how to install Lima BETA. Spent 2 hours and then gave up.

mmeyer724 commented 1 year ago

@thisisthekap, @JackEllis

~Here's a quick guide on how I got Lima/Colima running with Rosetta on my machine:~ see last edit

brew install --HEAD lima

git clone https://github.com/abiosoft/colima.git && cd colima
git checkout support-vz
make build
sudo make install

colima start

From there you should be able to use docker run ..., docker ps, etc, as usual.

Edit: Here's how you can verify that rosetta is being utilized

Screenshot 2022-11-28 at 3 25 35 PM

docker run -it --platform linux/amd64 ubuntu

EDIT 2: As of December 14th, you can now install Colima simply with brew install colima --HEAD. You don't need to clone the repo and build it yourself like before.

jjimenez commented 1 year ago

In case it is going to cause you issues, colima support-vz only enables rosetta on OSX 13 (ventura).

thisisthekap commented 1 year ago

@mmeyer724 Thank you very much for your work! I had to do some adjustments to the script you suggested (https://github.com/microsoft/mssql-docker/issues/734#issuecomment-1333696500).

MSSQL Server is now running just fine on M1 using Rosetta 2 😄

jasonreich commented 1 year ago

Yeah. My stack of x86 containers is running beautifully in Colima on the Rosetta 2 branch. Thanks! Would love to see this in Docker Desktop for Mac too.

lukas-hofstaetter commented 1 year ago

From there you should be able to use docker run ..., docker ps, etc, as usual.

Yeah, thank you. This approach is working for me, too. But the -vmount option does not work which makes docker useless for me. :-(

I tried fro example

touch foo
docker run -it --rm -v $(pwd):/$(basename $(pwd)) -w /$(basename $(pwd)) ubuntu  
#now we are inside the container    
ls 

But foo is then not visible inside the container.

thisisthekap commented 1 year ago

@eDeviser Try to add --network-address to colima start

lukas-hofstaetter commented 1 year ago

@thisisthekap , Thank you, but sorry, this does not solve the problem.

mmeyer724 commented 1 year ago

@thisisthekap , Thank you, but sorry, this does not solve the problem.

Which folder are you trying to mount into the container with -v? By default, Colima only allows mounting folders under /Users (so basically just your home directory). If the folder is located elsewhere, it won't work out of the box (but you won't see an error about this sadly, the folder will just appear empty).

Thankfully you can configure this using Colima's --mount option, for example:

colima delete # remove the existing VM first
colima start --mount "/Users:w,/some/other/folder/on/your/mac:w"

If you're still having problems, pls file an issue under the colima repo so we don't completely hijack this Docker thread with support posts for a competing product 😅

lukas-hofstaetter commented 1 year ago

If you're still having problems, pls file an issue under the colima repo

Yeah, you're right. This is not the right place. I would love to see this in docker desktop. An yes, my folder is inside /Users but it does not work.

adam-at-mobomo commented 1 year ago

@eDeviser, I do have this working, but I had to modify the instructions from @thisisthekap slightly. In addition to setting the driver to vz, I also had to explicitly set the mountType to virtiofs in the colima template. Did you try that as well? (microsoft/mssql-docker#734 (comment))

Note: this only works on macOS Ventura.

Compusa commented 1 year ago

Hi folks, please excuse my delay regarding timelines. So, right now we are focussing on getting virtiofs implemented as the default file sharing mechanism on Mac, we're very close on this one. Once complete, we'll immediately turn attention to Rosetta. I'm not able to disclose precise timelines, but...soon !

Any updates @christophermclellan ?

This feature is very much needed.

cmwilhelm commented 1 year ago

Edit: Here's how you can verify that rosetta is being utilized

Question: with this change, is rosetta used in both docker build and docker run, or just docker run?

velocitysystems commented 1 year ago

@christophermclellan Future support for Rosetta 2 emulation for amd64 images in Docker is exactly what is needed. This will allow macOS users to run container images such as SQL Server 2019/2022 on M1 devices without using third-party libs like Colima.

christophermclellan commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

pavankjadda commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

Amazing. Can't wait to Run SQL Server in M1 Mac

velocitysystems commented 1 year ago

Super! Well done Docker team.

mkurz commented 1 year ago

@christophermclellan Will this also be usuable when running docker within a Linux VM e.g. via Parallels Desktop? Or even more interesting: When using Asahi Linux directly on M1 machines?

ryanchapman commented 1 year ago

@christophermclellan Will this also be usuable when running docker within a Linux VM e.g. via Parallels Desktop? Or even more interesting: When using Asahi Linux directly on M1 machines?

Rosetta2 is only meant to be used with Virtualization.framework.

I tried it inside a Parallels VM and it didn't work. I was able to mount /Library/Apple/usr/libexec/oah/RosettaLinux/rosetta inside the Parallels VM, and install it using the instructions at [1]. When I try to run a x86_64 docker container in the VM, I get this error

$ docker logs 5c53755fbe28
rosetta error: Rosetta is only intended to run on Apple Silicon with a macOS host using Virtualization.framework with Rosetta mode enabled

[1] https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta?language=objc

idandam commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

Does it mean we can spin a container from Oracle DB images on Apple Silicon?

lukas-hofstaetter commented 1 year ago

the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January

Would you please give a link to the git branch? I would like to check if these changes will also be included into the 4.16 beta.

This is because there is also an issue regarding symbolic links (see here and here) and virtiofs which makes it impossible to build my stuff.

Compusa commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

Amazing. Where will we find the download of this beta, once published? Looking forward to check if this will resolve the issues for my particular case.

pavankjadda commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

I just downloaded the beta. However my container fails with same error as before. Is there something we should do?

Compusa commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

I just downloaded the beta. However my container fails with same error as before. Is there something we should do?

Where did you find the beta?

pavankjadda commented 1 year ago

Hi all, thanks for your patience on this one. We'll be releasing Rosetta for x86/amd64 emulation on Apple Silicon as a beta feature in the v4.16 release of Docker Desktop, which is scheduled for this Thursday 12-January. I'll circle back here once it's out !

I just downloaded the beta. However my container fails with same error as before. Is there something we should do?

Where did you find the beta?

https://docs.docker.com/desktop/release-notes/