ChrisTitusTech / website

My HUGO Website that I use for Videos, Blogs, and Redirects
74 stars 44 forks source link

docker-macos/ #87

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Docker Macos

Having Fun with Technology

https://christitus.com/docker-macos/

milesje commented 1 year ago

Any chance of adding the command needed to run this with DNF (Fedora) and/or other package managers?

peotr26 commented 1 year ago

Does the fact that it's containerize affects its performance compare to normal OSX-KVM running in a non-containerized environment?

SamCcp commented 1 year ago

for the non-linux dudes like me, can we do this on windows?

accik commented 1 year ago

for the non-linux dudes like me, can we do this on windows?

@SamCcp Windows 11 WSL has KVM/nested virtualization support. Win10 apparently is missing it, I wasn't able to get it working under Win10 WSL2 + Debian 11.

bers817 commented 1 year ago

@christitus thank you for this, I have a truenas scale setup with a Debian VM running docker and this will be a great addition to my other containers. If anyone is curious about this setup of mine I followed this Level1Techs forum.

IAmDarthMole commented 1 year ago

So I'm running focal, though my neofetch lists this as the OS:

Ubuntu 20.04.5 LTS x86_64.

So I updated the code to be:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

But when I run the apt install docker-ce -y command I get the follow error:

Reading package lists... Done Building dependency tree
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: docker-ce : Depends: containerd.io (>= 1.4.1) but it is not going to be installed Depends: docker-ce-cli but it is not going to be installed Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.9 is to be installed Recommends: docker-ce-rootless-extras but it is not going to be installed Recommends: pigz but it is not going to be installed E: Unable to correct problems, you have held broken packages.

Below is the complete output. Any ideas? Thank you in advance!

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

Reading package lists... Done Building dependency tree
Reading state information... Done ca-certificates is already the newest version (20211016~20.04.1). curl is already the newest version (7.68.0-1ubuntu2.14). software-properties-common is already the newest version (0.99.9.8). apt-transport-https is already the newest version (2.0.9). The following packages were automatically installed and are no longer required: libfwupdplugin1 libxmlb1 linux-headers-5.4.0-121 linux-headers-5.4.0-121-generic linux-headers-5.4.0-131 linux-headers-5.4.0-131-generic linux-image-5.4.0-121-generic linux-image-5.4.0-131-generic linux-modules-5.4.0-121-generic linux-modules-5.4.0-131-generic linux-modules-extra-5.4.0-121-generic linux-modules-extra-5.4.0-131-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

OK

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:6 http://us.archive.ubuntu.com/ubuntu focal-security InRelease Get:7 https://pkgs.tailscale.com/stable/ubuntu focal InRelease Fetched 5,542 B in 1s (4,155 B/s) Reading package lists... Done

Then the error already posted above.

robojerk commented 1 year ago

Any chance of adding the command needed to run this with DNF (Fedora) and/or other package managers?

@milesje

Setup Repository

sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \
    --add-repo \
    https://download.docker.com/linux/fedora/docker-ce.repo

Install Docker

sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Add user to docker group

sudo usermod -aG docker $USER

https://docs.docker.com/engine/install/fedora/

After you log back in, all the docker commands should work the same as they do for Chris.

mguiddir commented 1 year ago

I am trying it using Docker on Windows and run into this issue (See log): net stop winnat net start winnat

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e GENERATE_UNIQUE=true -e MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist" sickcodes/docker-osx:monterey

tommerty commented 1 year ago

Sadly I keep just getting

Attempting system restart...
MACH Reboot

And nothing actually happens. Screenshot for reference

tommerty commented 1 year ago

Update on my above post: So I managed to get it working, but on Big Sur. I guess any newer doesn't seem to work with Ryzen (at least Ryzen mobile 5800H in my case)

ankman commented 1 year ago

Thank you Chris! Runs smoothly on Windows 11. Got it running with this additional Youtube video: https://www.youtube.com/watch?v=BxBw16OCQME

Xeudoron commented 1 year ago

First of all, thank you Chris. You opened me the door to learn docker with Portainer. I'm using Ubuntu in WSL2 on my laptop and I appreciate this easier non cli way to learn containers. One thing I stumbled upon while following your article was adding Docker’s official GPG key while setting up the repository:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable"

which is on Ubuntu 22.04 deprecated (explained here) and the "official way" to add docker repo gpg key is:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

I'd say it is safer and a bit more general approach to adding any gpg key.

milesje commented 1 year ago

So apparently this only works when using X11. It will crash when using wayland, but as soon as I switched to X11 it now works. Well almost, I'm able to boot into the recovery and erase the disk, but when I attempt to perform the Re-Install it fails saying it can't contact the recovery server.

coxe87b commented 1 year ago

Excellent guide thank you Chris.

I just wanted to add that I had a few hiccups on Arch Linux when doing this; 1) I had to have package xorg-xhost installed and run "xhost +" to disable access control from X11 otherwise I would get a gtk initialization error. 2) I moved the /var/lib/docker directory to a larger HDD on my system and made a symlink to the directory (as my root FS is only a 40GB partition on my NVMe SSD) and on my first attempt, I inadvertently filled my entire root partition which then made the MacOS container hang on installation and it took me a few minutes to work out what was happening.