docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.63k stars 1.97k forks source link

How to get newest docker engine on MacOS with open-source Docker? #4895

Open kumikumi opened 3 years ago

kumikumi commented 3 years ago

After installing both docker and docker-machine from Homebrew and setting up docker-machine with a VirtualBox driver, the docker version command reports that my client version is 20.10.8 whereas the server version is 19.03.12.

I would like to upgrade to the latest server version (20.10.8 at the time of posting), that should still be open source if I'm not mistaken.

As it appears that docker-machine is not actively maintained anymore, what is the correct way to upgrade to the latest docker server version (without using proprietary Docker software)? Are there any instructions anywhere? Thanks

afbjorklund commented 3 years ago

Version 19.03 is indeed the last and final version of boot2docker, the Linux distribution of Docker machine. It is now deprecated

You can use an Ubuntu VM and install Docker in it, but docker-machine only does this for cloud drivers (and doesn't support 20.10)

afbjorklund commented 3 years ago

Like so: https://boot2podman.github.io/2020/07/22/machine-replacement.html

(mostly written for use with Podman, but also shows instructions for Docker)

vagrant init ubuntu/focal64
vagrant up
vagrant ssh

See https://www.vagrantup.com/

vagrant@ubuntu-focal:~$ curl -fsSL https://get.docker.com | sudo sh
vagrant@ubuntu-focal:~$ sudo usermod -aG docker $USER
vagrant@ubuntu-focal:~$ newgrp docker

See https://docs.docker.com/engine/install/ubuntu/


The docker client (installed with brew) uses ssh to talk to the docker daemon socket in the VM.

export DOCKER_HOST=ssh://vagrant@127.0.0.1:2222

ssh-add -k .vagrant/machines/default/virtualbox/private_key

Not all third party tools support ssh: yet, so you might have to upgrade those or set up legacy tcp:.

It is also possible to tunnel the unix: socket over ssh, to create a local file for clients not yet on 18.09 (that added ssh)


You could use another virtualization solution, by doing the same commands as in the Vagrantfile...

lfoalpha commented 3 years ago

examples docker-machine with vagrant.

<example>/
|__ Vagrantfile
|__ docker-compose.yml ... example for docker container(php:apache).
|__ index.php          ... example php source.

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/hirsute64"

  config.vm.network "private_network", ip: "192.168.33.10"

  # mapping working dir to vm as same path.
  config.vm.synced_folder ENV["PWD"], ENV["PWD"]
end

docker-compose.yml

version: "3"
services:
  php:
    image: "php:apache"
    volumes:
      - ".:/var/www/html"
    ports:
      - "80:80"

index.php

<?php
phpinfo();

launch vagrant vm.

vagrant up

register to docker-machine with generic driver.

docker-machine create --driver generic \
           --generic-ip-address "192.168.33.10" \
           --generic-ssh-key $PWD/.vagrant/machines/default/virtualbox/private_key \
           --generic-ssh-port 22 \
           --generic-ssh-user "vagrant" \
           docker-with-vagrant-vm

apply docker-machine environment variables.

eval $(docker-machine env docker-with-vagrant-vm)

list docker machines.

docker-machine ls
NAME                     ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER      ERRORS
docker-with-vagrant-vm   *        generic      Running   tcp://192.168.33.10:2376            v20.10.8

launch docker container.

docker-compose up -d

open browser.

open http://192.168.33.10/
afbjorklund commented 3 years ago

Nice! I was thinking to do a vagrant-machine to wrap it (Vagrant), but in retrospect a Vagrant machine-driver would have been better...

kumikumi commented 3 years ago

Here is another project that I'm following closely: https://github.com/abiosoft/colima

It is the most promising Docker Desktop replacement for Mac I have seen and I have had the most success with it so far.