Table of Contents
  • Home
  • /
  • Blog
  • /
  • Step-by-Step Guide: Installing Docker Desktop on macOS
May 30, 2024
|
15m

Step-by-Step Guide: Installing Docker Desktop on macOS


Install Docker Desktop on macOS - Step-by-Step Guide

You can't imagine how easy it is to create, deploy, and manage containers after the introduction of Docker technology. It's just a matter of a few seconds to deploy an application, services, or operating system within an isolated containers. However, to play with these isolated containers, it is necessary to have Docker installed on your machine. Since containers are natively built on Linux, it's not a big deal to install Docker Engine on any Linux distribution. So, what about the non-Linux machines, Can't you use Docker Containers on other platforms? It's neither a big deal to play with Docker Containers on non-Linux operating systems like Windows and Mac too upon the release of Docker Desktop.In this tutorial post, we are learning the installation of Docker Desktop on a Mac machine. If you want to install Docker on a Linux machine, we have covered that too on a different tutorial post.

If you bear with us until the end of this post, we ensure you will gain all the knowledge required to install Docker Desktop on a Mac machine.

Background of Docker Desktop

Running Docker containers on Linux is straightforward because Linux-based distributions share a common kernel. However, non-Linux operating systems like Windows and macOS do not share this kernel. This fundamental difference means that Docker containers, which rely on Linux control groups and namespaces, cannot run directly on these platforms.

Linux containers run smoothly on a Linux Docker because they share the same kernel. However, running a Linux container on a Windows environment involves an underlying mechanism. When Docker is installed on Windows and a Linux container is executed, it runs within a Linux virtual machine (VM) inside the Windows environment. This setup, while functional, adds a layer of complexity and potential performance issues.

Docker's initial workaround for this was Docker Machine, which used Oracle's VirtualBox to create a small Linux-based VM to run the Docker engine. Users had to connect their Docker CLI with this VM, which required knowledge of VirtualBox for tasks like exposing network ports or mounting directories. This solution had two major drawbacks:

  • Complexity: Users needed to understand VirtualBox and manage it for various tasks, making it difficult for some to adopt Docker.

  • Performance Issues: Docker Machine was not as performant as native Linux Docker, suffering from slow disk performance and network issues due to its dependency on VirtualBox.

To address these issues, Docker introduced Docker Desktop in 2016. Docker Desktop offered a more streamlined and efficient solution by utilizing Apple's native hypervisor (VirtualKit) on macOS and Hyper-V on Windows. It improved the user experience in three significant ways:

  • Performance: Docker Desktop uses a smaller and faster VM, enhancing overall performance.

  • Ease of Use: It automatically handles volume mounting and network port exposure, simplifying configuration.

  • User Interface: Docker Desktop provides a graphical user interface (GUI) to facilitate VM configuration and common tasks, such as creating Kubernetes clusters.

By using Docker Desktop on macOS, you can enjoy a seamless Docker experience similar to running Docker on Linux, without the need for manual setup or extensive knowledge of virtualization tools. It simplifies the process of developing, testing, and deploying containerized applications on your Mac.

If you want to know more about the Docker and Containers, visit these pages:

Now that we have a better understanding of the background and importance of Docker Desktop, let's move on to the installation process.

Prerequisites to Install Docker Desktop on Mac

Before you begin the installation process, it's important to ensure that your Mac meets the necessary requirements to run Docker Desktop. Let's go through the prerequisites to ensure a smooth installation experience.

System Requirements

To install and run Docker Desktop on your Mac, your machine must meet the following system requirements:

  • macOS Version: Docker Desktop requires macOS 10.15 (Catalina) or newer. It is compatible with both Intel and Apple Silicon (M1 and M2) processors. To check your macOS version, click on the Apple menu in the top-left corner of your screen and select "About This Mac."

  • Memory: Your Mac should have at least 4 GB of RAM. However, for optimal performance, especially when running resource-intensive applications or multiple containers simultaneously, it is recommended to have 8 GB or more. You can view your Mac's memory information in the "About This Mac" window.

  • Disk Space: Docker Desktop requires approximately 1 GB of disk space for installation. However, it is recommended to have at least 10 GB of free disk space to accommodate container images, volumes, and other Docker-related files. You can check your available disk space by opening the Finder and selecting "About This Mac" from the Apple menu.

Virtualization Support

Docker Desktop utilizes virtualization technology to run Linux containers on macOS. Therefore, your Mac must have virtualization support enabled. Most modern Macs have virtualization enabled by default, but it's a good practice to verify this before proceeding with the installation.

To check if virtualization is enabled on your Mac, follow these steps:

  1. Open the Terminal application from the Applications > Utilities folder or by using Spotlight search.

  2. In the Terminal, run the following command and press Enter:

sysctl -a | grep -E --color 'machdep.cpu.features|VMX'

3. If virtualization is enabled, you should see output similar to the following: If you see VMX highlighted in the output (for Intel processors) or VMFT (for Apple Silicon processors), virtualization is enabled on your Mac.

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

With these prerequisites met, you're ready to proceed with the installation of Docker Desktop on your Mac. In the next section, we'll walk through the step-by-step installation process.

Installing Docker Desktop on macOS from the Installer Package

Now that you have confirmed your Mac meets the prerequisites, let's proceed with the installation of Docker Desktop using the installer package. Follow these step-by-step instructions to get Docker Desktop up and running on your Mac.

Step 1: Download Docker Desktop

1. Open your web browser and visit the official Docker website at https://www.docker.com/products/docker-desktop/.

2. On the Docker Desktop for Mac page, click on the "Download for Mac" button. If you have an Apple Silicon Mac (M1 or M2 chip), make sure to select the "Apple Chip" option.

3. The Docker Desktop installer package (.dmg file) will start downloading. Once the download is complete, proceed to the next step.

Step 2: Install Docker Desktop

1. Locate the downloaded Docker Desktop installer package (.dmg file) in your Downloads folder or the location you specified during the download.

1. Double-click on the .dmg file to open it. This will mount the disk image and display its contents.

2. In the mounted disk image, you will see the Docker icon and an Applications folder shortcut. Click and drag the Docker icon onto the Applications folder shortcut. This will copy the Docker Desktop application to your Mac's Applications folder.

3. Wait for the copying process to complete. This may take a few moments depending on your system's speed.

4. Once the copying is finished, you can close the disk image window and optionally eject the mounted disk image.

Step 3: Launch Docker Desktop

1. Open the Finder and navigate to the Applications folder.

2. Locate the Docker application and double-click on it to launch Docker Desktop.

3. Since Docker Desktop was downloaded from the internet, macOS may display a security prompt asking for your confirmation to open the application. Click on the "Open" button to proceed.

4. Docker Desktop will start initializing. You may be prompted to enter your system password to authorize the installation of additional components. Enter your password and click "OK" to continue.

5. Docker Desktop will display the Docker subscription agreement. Read through the agreement and click on the "Accept" button to accept the terms and proceed.

Step 4: Verify Docker Desktop Installation

1. Once Docker Desktop finishes initializing, you will see the Docker Desktop user interface.

2. Look for the Docker icon in the menu bar at the top of your screen. If you see the Docker whale icon, Docker Desktop is running.

3. To further verify the installation, open the Terminal and run the following command:

docker --version

This command will display the installed Docker version, confirming that Docker is properly installed and accessible from the command line.

Congratulations! You have successfully installed Docker Desktop on your Mac using the installer package. You can now start exploring and leveraging the power of containerization on your macOS machine.

In the next section, we will discuss an alternative method of installing Docker Desktop using Homebrew, a popular package manager for macOS.

Installing Docker Desktop on macOS Using Homebrew

If you prefer using the command line and package managers, you can install Docker Desktop on your Mac using Homebrew. Homebrew is a popular open-source package management system that simplifies the installation of software on macOS. Follow these step-by-step instructions to install Docker Desktop using Homebrew.

Step 1: Install Homebrew

1. Open the Terminal application on your Mac. You can find it in the Applications > Utilities folder or by using Spotlight search.

2. In the Terminal, paste the following command and press Enter: This command will download and install Homebrew on your Mac.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. During the installation process, you may be prompted to enter your system password. Type your password and press Enter to proceed.

4. Wait for the Homebrew installation to complete. Once finished, you will see a "Installation successful!" message in the Terminal.

Step 2: Install Docker Desktop using Homebrew

1. With Homebrew installed, you can now use it to install Docker Desktop. In the Terminal, run the following command:

brew install docker --cask

The --cask option specifies that Docker Desktop is a GUI application rather than a command-line tool.

2. Homebrew will start downloading and installing Docker Desktop along with its dependencies. This process may take several minutes depending on your internet connection speed.

3. Once the installation is complete, you will see a message indicating that Docker Desktop was successfully installed.

The next steps: launch the Docker Desktop and Verify the installations remain same as shown in the previous installation method. Follow the Step 3 and Step 4 from the previous section. 

By installing Docker Desktop using Homebrew, you have the advantage of easily managing updates and uninstalling Docker Desktop through the Homebrew package manager. This is how you should installed Docker Desktop on your Mac using Homebrew. It's easy, isn't it!

Next Is What?

Now that you have successfully installed Docker Desktop on your Mac, there are a few post-installation steps and configurations you can perform to enhance your Docker experience and tailor it to your needs.

1. Verify Docker Installation

To ensure that Docker is properly installed and functioning, you can run a simple "Hello, World" container. Open the Terminal and execute the following command:

docker run hello-world

Docker will download the "hello-world" image (if it doesn't exist locally) and create a container from it. If the installation is successful, you should see a message that says "Hello from Docker!" along with some additional information.

2. Configure Docker Resources

Docker Desktop allows you to configure the resources allocated to the Docker Engine. By default, Docker Desktop is set to use 2 CPUs, 2 GB of RAM, 1 GB of swap, and 59 GB of disk image size. However, you can adjust these settings based on your machine's capabilities and requirements.

To modify the resource settings:

1. Click on the Docker icon in the menu bar and select "Preferences" (or "Settings" on some versions).

2. In the Docker Desktop preferences window, go to the "Resources" tab.

3. Adjust the CPU, RAM, swap, and disk image size as needed.

4. Click "Apply & Restart" to save the changes and restart Docker Desktop.

3. Enable Kubernetes (Optional)

Docker Desktop comes with built-in support for Kubernetes, an open-source container orchestration system. If you plan to use Kubernetes for managing and deploying containerized applications, you can enable it within Docker Desktop.

To enable Kubernetes:

1. Click on the Docker icon in the menu bar and select "Preferences" (or "Settings" on some versions).

2. In the Docker Desktop preferences window, go to the "Kubernetes" tab.

3. Check the "Enable Kubernetes" option.

4. Click "Apply & Restart" to enable Kubernetes and restart Docker Desktop.

Once enabled, you can use the kubectl command-line tool to interact with your local Kubernetes cluster.

4. Explore Docker Hub

Docker Hub is a public registry that contains a vast collection of pre-built Docker images contributed by the community and official sources. You can explore Docker Hub to find images for various software applications, frameworks, and operating systems.

To explore Docker Hub:

1. Open your web browser and visit https://hub.docker.com/.

2. Use the search bar to find images related to your interests or requirements.

3. You can browse popular images, official images, and user-contributed images.

4. To use an image, you can pull it using the docker pull command followed by the image name.

5. Learn Docker Commands

To make the most out of Docker, familiarize yourself with common Docker commands. Here are a few essential commands to get you started:

- docker run: Creates and starts a new container from an image.

- docker ps: Lists running containers.

- docker stop: Stops a running container.

- docker rm: Removes a stopped container.

- docker images: Lists locally available images.

- docker pull: Downloads an image from a registry.

- docker push: Pushes an image to a registry.

You can find more commands and their detailed usage in the Docker command-line reference.

Uninstalling Docker Desktop from Mac

If you no longer need Docker Desktop on your Mac or want to start fresh with a new installation, you can uninstall it from your system. In this section, we'll cover two methods to uninstall Docker Desktop: using the graphical interface and using the command line.

Method 1: Uninstalling Docker Desktop using the Graphical Interface

1. Open the Finder and navigate to the Applications folder.

2. Locate the Docker application and drag it to the Trash. This will remove the Docker Desktop application from your Mac.

3. To remove additional Docker-related files and configurations, follow these steps:

- Open the Finder and press Shift+Command+G to open the "Go to Folder" dialog.

- Type ~/Library/ and press Enter to open the Library folder.

- Look for the following folders and files, and move them to the Trash:

- ~/Library/Application Support/Docker

- ~/Library/Caches/com.docker.docker

- ~/Library/Containers/com.docker.docker

- ~/Library/Group Containers/group.com.docker

- ~/Library/Preferences/com.docker.docker.plist

- ~/Library/Saved Application State/com.electron.docker.savedState

4. Empty the Trash to permanently delete the Docker Desktop application and its associated files.

Method 2: Uninstalling Docker Desktop using the Command Line

1. Open the Terminal application on your Mac.

2. Run the following command to stop and remove any running Docker containers and images:

docker container stop $(docker container ls -aq)
docker container rm $(docker container ls -aq)
docker image rm $(docker image ls -aq)

This command will stop all running containers, remove all containers, and remove all images from your local machine.

3. If you installed Docker Desktop using Homebrew, you can uninstall it by running the following command:

brew uninstall docker --cask

This command will uninstall the Docker Desktop application using Homebrew.

4. To remove additional Docker-related files and configurations, run the following commands in the Terminal:

rm -rf ~/Library/Application\ Support/Docker
rm -rf ~/Library/Caches/com.docker.docker
rm -rf ~/Library/Containers/com.docker.docker
rm -rf ~/Library/Group\ Containers/group.com.docker
rm -rf ~/Library/Preferences/com.docker.docker.plist
rm -rf ~/Library/Saved\ Application\ State/com.electron.docker.savedState

These commands will remove the Docker-related folders and files from your system.

5. Finally, remove the Docker command-line tools by running the following command: This command will remove the Docker command-line tools from your system.

After following either of the above methods, Docker Desktop will be completely uninstalled from your Mac.

Please note that uninstalling Docker Desktop will remove all containers, images, and volumes associated with it. Make sure to backup any important data or configurations before proceeding with the uninstallation.

If you decide to reinstall Docker Desktop in the future, you can follow the installation instructions covered earlier in this blog post.

By knowing how to uninstall Docker Desktop, you can easily remove it from your Mac when it's no longer needed, freeing up system resources and ensuring a clean setup for future installations.

Throughout this tutorial, we covered the background of Docker Desktop, its significance for running Docker containers on macOS, and the step-by-step installation process using both the installer package and Homebrew. We also explored post-installation steps and configurations to enhance your Docker experience, as well as the process of uninstalling Docker Desktop when needed.

With Docker Desktop at your fingertips, you can effortlessly create, deploy, and manage containers on your Mac, enabling a consistent and efficient development environment. As you continue to explore Docker, remember to refer to the official Docker documentation for in-depth information and best practices.

We hope this post helps Understand installing Docker Desktop on macOS with this step-by-step guide. We are going to end this post for now, we will cover more information about the Docker in the up coming articles. Please keep visiting thesecmaster.com for more such technical information. Visit our social media page on Facebook, Instagram,  LinkedIn, Twitter, Telegram, Tumblr, & Medium and subscribe to receive information like this. 

You may also like these articles:

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Tutorials

View All

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.

Tools

Featured

View All

Learn Something New with Free Email subscription

Subscribe

Subscribe