1Jan

Dinghy Vs Docker For Mac

1 Jan 2000admin
Dinghy Vs Docker For Mac 4,8/5 8468 votes
Estimated reading time: 8 minutes

To be open: I am very new to docker and k8s, that is why I am trying to get hands-on time with both on my laptop, with docker for mac. I would just like to access services via a name (e.g. The one below) instead of via the IP.

If you already have an installation of Docker Toolbox, read these topicsfirst to learn how Docker Desktop on Mac and Docker Toolbox differ, and how they cancoexist.

The Docker Toolbox environment

Docker Toolbox installs docker, docker-compose, and docker-machine in/usr/local/bin on your Mac. It also installs VirtualBox. At installation time,Toolbox uses docker-machine to provision a VirtualBox VM called default,running the boot2docker Linux distribution, with Docker Enginewith certificates located on your Mac at$HOME/.docker/machine/machines/default.

Before you use docker or docker-compose on your Mac, you typically use thecommand eval $(docker-machine env default) to set environment variables sothat docker or docker-compose know how to talk to Docker Engine running onVirtualBox.

This setup is shown in the following diagram.

The Docker Desktop on Mac environment

Docker Desktop on Mac is a Mac-native application, that you install in /Applications.At installation time, it creates symlinks in /usr/local/bin for docker anddocker-compose and others, to the commands in the applicationbundle, in /Applications/Docker.app/Contents/Resources/bin.

Here are some key points to know about Docker Desktop on Mac before you get started:

  • Docker Desktop uses HyperKit instead of Virtual Box. Hyperkit is a lightweight macOS virtualization solution built on top of Hypervisor.framework in macOS 10.10 Yosemite and higher.

  • When you install Docker Desktop on Mac, machines created with Docker Machine are not affected.

  • Docker Desktop does not use docker-machine to provision its VM.The Docker Engine API is exposed on asocket available to the Mac host at /var/run/docker.sock. This is thedefault location Docker and Docker Compose clients use to connect tothe Docker daemon, so you can use docker and docker-compose CLI commandson your Mac.

This setup is shown in the following diagram.

With Docker Desktop on Mac, you only get (and only usually need) one VM, managed by Docker Desktop. Docker Desktop automatically upgrades the Docker client and daemon when updates are available.

Also note that Docker Desktop can’t route traffic to containers, so you can’tdirectly access an exposed port on a running container from the hosting machine.

If you do need multiple VMs, such as when testing multi-node swarms, you cancontinue to use Docker Machine, which operates outside the scope of Docker Desktop. See Docker Toolbox and Docker Desktopcoexistence.

Setting up to run Docker Desktop on Mac

  1. Check whether Toolbox DOCKER environment variables are set:

    If this command returns no output, you are ready to use Docker Desktop.

    If it returns output (as shown in the example), unset the DOCKER environment variables to make the client talk to the Docker Desktop Engine (next step).

  2. Run the unset command on the following DOCKER environment variables tounset them in the current shell.

Now, this command should return no output.

If you are using a Bash shell, you can use unset ${!DOCKER_*} to unset all DOCKER environment variables at once. (This does not work in other shells such as zsh; you need to unset each variable individually.)

Note: If you have a shell script as part of your profile that sets theseDOCKER environment variables automatically each time you open a commandwindow, then you need to unset these each time you want to use Docker Desktop.

If you install Docker Desktop on a machine where Docker Toolbox is installed.

Docker Desktop replaces the docker and docker-compose command lines in/usr/local/bin with symlinks to its own versions.

See also Unset environment variables in the currentshellin the Docker Machine topics.

Docker Toolbox and Docker Desktop coexistence

You can use Docker Desktop and Docker Toolbox together on the same machine. Whenyou want to use Docker Desktop make sure all DOCKER environment variables areunset. You can do this in bash with unset ${!DOCKER_*}. When you want to useone of the VirtualBox VMs you have set with docker-machine, just run a eval$(docker-machine env default) (or the name of the machine you want to target).This switches the current command shell to talk to the specified Toolboxmachine.

This setup is represented in the following diagram.

Using different versions of Docker tools

The coexistence setup works as is as long as your VirtualBox VMs provisionedwith docker-machine run the same version of Docker Engine as Docker Desktop.If you need to use VMs running older versions of Docker Engine, you can use atool like Docker Version Manager to manageseveral versions of docker client.

Checking component versions

Ideally, the Docker CLI client and Docker Engine should be the same version.Mismatches between client and server, and host machines you might havecreated with Docker Machine can cause problems (client can’t talk to the serveror host machines).

If you have already installed Docker Toolbox, and theninstalled Docker Desktop, you might get a newer version of the Docker client. Run docker version in a command shell to see client and server versions. In this example, the client installed with Docker Desktop is Version: 19.03.1 and the server (which was installed earlier with Toolbox) is Version: 19.03.2.

Also, if you created machines with Docker Machine (installed with Toolbox) thenupgraded or installed Docker Desktop, you might have machines running differentversions of Engine. Run docker-machine ls to view version information for themachines you created. In this example, the DOCKER column shows that each machineis running a different version of server.

You might also run into a similar situation with Docker Universal Control Plane (UCP).

There are a few ways to address this problem and keep using your oldermachines. One solution is to use a version manager likeDVM.

Migrating from Docker Toolbox to Docker Desktop on Mac

Docker Desktop does not propose Toolbox image migration as part of itsinstaller since version 18.01.0. You can migrate existing DockerToolbox images with the scripts described below. (This migrationcannot merge images from both Docker and Toolbox: any existing Docker image isreplaced by the Toolbox images.)

Run the following shell commands in a terminal. You need a workingqemu-img; it is part of the qemu package in both MacPorts and Brew:

First, find your Toolbox disk images. You probably have just one:~/.docker/machine/machines/default/disk.vmdk.

Second, find out the location and format of the disk image used by your DockerDesktop.

In this case the format is raw (it could have been qcow2), and the locationis ~/Library/Containers/com.docker.docker/Data/vms/0/.

Then:

  • if your format is qcow2, run
  • if your format is raw, run the following command. If you are short on diskspace, it is likely to fail.

Finally (optional), if you are done with Docker Toolbox, you may fullyuninstallit.

How do I uninstall Docker Toolbox?

You might decide that you do not need Toolbox now that you have Docker Desktop,and want to uninstall it. For details on how to perform a clean uninstall ofToolbox on Mac, see How to uninstallToolbox in theToolbox Mac topics.

mac, windows, alpha, beta, toolbox, docker-machine, tutorial

Legacy desktop solution. Docker Toolbox is for older Mac and Windows systems that do not meet the requirements of Docker Desktop for Mac and Docker Desktop for Windows. We recommend updating to the newer applications, if possible.

Estimated reading time: 9 minutes

Docker Toolbox provides a way to use Docker on older Macsthat do not meetminimal system requirements for Docker Desktop for Mac.

What you get and how it works

Docker Toolbox includes the following Docker tools:

  • Docker CLI client for running Docker Engine to create images and containers
  • Docker Machine so you can run Docker Engine commands from macOS terminals
  • Docker Compose for running the docker-compose command
  • Kitematic, the Docker GUI
  • the Docker QuickStart shell preconfigured for a Docker command-line environment
  • Oracle VM VirtualBox

Because the Docker Engine daemon uses Linux-specifickernel features, you can’t run Docker Engine natively onmacOS with Docker Toolbox. Instead, you must use theDocker Machine command, docker-machine, to create andattach to a small Linux VM on your machine. This VM hostsDocker Engine for you on your Mac.

Tip: One of the advantages of the newerDocker Desktop for Mac solution is thatit uses native virtualization and does not requireVirtualBox to run Docker.

Step 1: Check your version

Your Mac must be running macOS 10.8 “Mountain Lion” or newer to run Dockersoftware. To find out what version of the OS you have:

  1. Choose About this Mac from the Apple menu.

    The version number appears directly below the words macOS.

  2. If you have the correct version, go to the next step.

    If you aren’t using a supported version, you could consider upgrading your operating system.

    If you have macOS 10.10.3 Yosemite or newer, consider using Docker Desktop for Mac instead. It runs natively on the Mac, so there is no need for a pre-configured Docker QuickStart shell. It uses the native macOS Hypervisor framework for virtualization, instead of Oracle VirutalBox. Full install prerequisites are provided in the Docker Desktop for Mac topic in Docker Desktop for Mac.

Step 2: Install Docker Toolbox

Note: Docker are no longer maintaining the download.docker.com url forDocker Toolbox, therefore an unsigned warning (verified publisher dialog) isdisplayed during the installation process.

  1. To download the latest version of Docker Toolbox, go to ToolboxReleases and download thelatest .pkg file.

  2. Install Docker Toolbox by double-clicking the package or by right-clickingand choosing “Open” from the pop-up menu.

    The installer launches an introductory dialog, followed by an overview of what’s installed.

  3. Press Continue to install the toolbox.

    The installer presents you with options to customize the standard installation.

    By default, the standard Docker Toolbox installation:

    • installs binaries for the Docker tools in /usr/local/bin
    • makes these binaries available to all users
    • updates any existing Virtual Box installation

    For now, don’t change any of the defaults.

  4. Press Install to perform the standard installation.

    The system prompts you for your password.

  5. Provide your password to continue with the installation.

    When it completes, the installer provides you with some shortcuts. You can ignore this for now and click Continue.

    Then click Close to finish the installer.

Step 3: Verify your installation

To run a Docker container, you:

  • create a new (or start an existing) Docker Engine host running
  • switch your environment to your new VM
  • use the docker client to create, load, and manage containers

Once you create a machine, you can reuse it as often as you like. Like anyVirtual Box VM, it maintains its configuration between uses.

  1. Open the Launchpad and locate the Docker Quickstart Terminal icon.

  2. Click the icon to launch a Docker Quickstart Terminal window.

    The terminal does a number of things to set up Docker Quickstart Terminal for you.

  3. Click your mouse in the terminal window to make it active.

    If you aren’t familiar with a terminal window, here are some quick tips.

    The prompt is traditionally a $ dollar sign. You type commands into thecommand line which is the area after the prompt. Your cursor is indicatedby a highlighted area or a that appears in the command line. Aftertyping a command, always press RETURN.

  4. Type the docker run hello-world command and press RETURN.

    You can use the icons for private and commercial projects, blogs and web-sites for free, without any restrictions whatsoever. Flaticon This icon set was designed by and is now released as a gift for Smashing Magazine and its readers.

    The command does some work for you, if everything runs well, the command’s output looks like this:

Optional: Add shared directories

By default, Toolbox only has access to the /Users directory and mounts it intothe VMs at /Users. If your project lives elsewhere or needs access to otherdirectories on the host filesystem, you can add them.

Use the VirtualBox GUI

You can configure shared folders in the VirtualBox UI.

  1. Open the VirtualBox UI.

  2. Click the Settings gear, then go to Shared Folders.

  3. Select any existing listing under Machine Folders, thenclick the + icon.

    • Choose the Folder Path on the host, enter the Folder Namefor within the VM (or take the default, which is the same nameas on the host), and configure any additional options you need.

    • Choose Auto-mount if you want the folder to automaticallybe mounted into the VM, and choose Make Permanent for itto be considered a permanently shared folder.

  4. Click OK to add the new folder to the Shared Folders list.

  5. Click OK again to save your changes and exit the Settings dialog.

    If your Mac is already running the latest version, restart it. MacOS includes a built-in tool that removes known malware when you restart your Mac.Check your Applications folder to see if you have any apps that you didn’t expect. 0 ad game.

Use the command line

You can configure shared folders using a command like the following:

This command mounts /some/mount/location into the VM at /your-other-share-hame,owned by UID 1000 and GID 50.

Note: The autommount and permanent mount options are not supported usingthe command line.

How to uninstall Toolbox

Removing Toolbox involves removing all the Docker components it includes.

A full uninstall also includes removing the local and remote machinesyou created with Docker Machine. In some cases, you might want to keepmachines created with Docker Machine.

For example, if you plan to re-install Docker Machine as a part ofDocker Desktop for Mac you can continue to manage those machines throughDocker. Or, if you have remote machines on a cloud provider and youplan to manage them using the provider, you wouldn’t want to removethem. So the step to remove machines is described here as optional.

To uninstall Toolbox on a Mac, do the following:

  1. List your machines.

  2. Optionally, remove each machine. For example:

    This step is optional because if you planto re-install Docker Machine as a partof Docker Desktop for Mac, you can import andcontinue to manage those machines through Docker.

  3. In your “Applications” folder, remove the “Docker” directory,which contains “Docker Quickstart Terminal” and “Kitematic”.

  4. Run the following in a command shell to fully remove Kitematic:

  5. Remove the docker, docker-compose, and docker-machine commands fromthe /usr/local/bin folder. Docker Desktop for Mac and Brew may also haveinstalled them; in case of doubt leave them, or reinstall them via Brew, orrerun Docker Desktop for Mac (no need to reinstall it).

  6. Optionally, remove the ~/.docker/machine directory.

    This directory stores some configuration and/or state, such as informationabout created machines and certificates.

  7. Uninstall Oracle VirtualBox, which is installed as a part of theToolbox install.

Next steps

  • Try the Get started tutorial.

  • Dig in deeper with more tutorials and examples on building images, running containers, networking, managing data, and storing images on Docker Hub.

docker, documentation, install, toolbox, mac