- Install Docker Desktop on Mac
- System requirements
- Mac with Intel chip
- Mac with Apple silicon
- Install and run Docker Desktop on Mac
- Quick start guide
- Updates
- Uninstall Docker Desktop
- Marcin PilЕ›niak
- How to install Docker on Mac OS using brew?
- What is Docker?
- Other ways to install it
- Docker.com – first method
- Docker Toolbox – second method
- Install
- Useful tools
- docker-machine
- docker-compose
- How to use
- Access by domain
- Potential problems
- Sharing files
- Speed of I/O process
- Access via domain/IP
- A complete one-by-one guide to install Docker on your Mac OS using Homebrew
- Beginner’s guide to install and run Docker on Mac OS
- Configurations
- Step-by-step Installation Process
- Docker installation via Homebrew
- Docker-Machine installation via Homebrew
- VirtualBox installation via Homebrew
- Create a new virtual machine
- What we have done?
- Docker Machine CLI commands
Install Docker Desktop on Mac
Estimated reading time: 7 minutes
Welcome to Docker Desktop for Mac. This page contains information about Docker Desktop for Mac system requirements, download URLs, instructions to install and update Docker Desktop for Mac.
Download Docker Desktop for Mac
System requirements
Your Mac must meet the following requirements to install Docker Desktop successfully.
Mac with Intel chip
macOS must be version 10.14 or newer. That is, Mojave, Catalina, or Big Sur. We recommend upgrading to the latest version of macOS.
If you experience any issues after upgrading your macOS to version 10.15, you must install the latest version of Docker Desktop to be compatible with this version of macOS.
Docker supports Docker Desktop on the most recent versions of macOS. That is, the current release of macOS and the previous two releases. As new major versions of macOS are made generally available, Docker stops supporting the oldest version and supports the newest version of macOS (in addition to the previous two releases). Docker Desktop currently supports macOS Mojave, macOS Catalina, and macOS Big Sur.
At least 4 GB of RAM.
VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop.
Mac with Apple silicon
You must install Rosetta 2 as some binaries are still Darwin/AMD64. To install Rosetta 2 manually from the command line, run the following command:
Install and run Docker Desktop on Mac
Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder.
Double-click Docker.app in the Applications folder to start Docker. In the example below, the Applications folder is in “grid” view mode.
The Docker menu () displays the Docker Subscription Service Agreement window. It includes a change to the terms of use for Docker Desktop.
Here’s a summary of the key changes:
- Our Docker Subscription Service Agreement includes a change to the terms of use for Docker Desktop
- It remains free for small businesses (fewer than 250 employees AND less than $10 million in revenue), personal use, education, and non-commercial open source projects.
- It requires a paid subscription for professional use in larger enterprises.
- The effective date of these terms is August 31, 2021. There is a grace period until January 31, 2022 for those that will require a paid subscription to use Docker Desktop.
- The existing Docker Free subscription has been renamed Docker Personal and we have introduced a Docker Business subscription .
- The Docker Pro, Team, and Business subscriptions include commercial use of Docker Desktop.
Click the checkbox to indicate that you accept the updated terms and then click Accept to continue. Docker Desktop starts after you accept the terms.
If you do not agree to the terms, the Docker Desktop application will close and you can no longer run Docker Desktop on your machine. You can choose to accept the terms at a later date by opening Docker Desktop.
For more information, see Docker Desktop License Agreement. We recommend that you also read the Blog and FAQs to learn how companies using Docker Desktop may be affected.
Quick start guide
If you’ve just installed the app, Docker Desktop launches the Quick Start Guide. The tutorial includes a simple exercise to build an example Docker image, run it is a container, push and save the image to Docker Hub.
Congratulations! You are now successfully running Docker Desktop. Click the Docker menu () to see Preferences and other options. To run the Quick Start Guide on demand, select the Docker menu and then choose Quick Start Guide.
Updates
When an update is available, Docker Desktop displays an icon to indicate the availability of a newer version.
Starting with Docker Desktop 4.1.0, the Software Updates section in the General tab also notifies you of any updates available to Docker Desktop. You can choose to download the update right away, or click the Release Notes option to learn what’s included in the updated version. If you are on a Docker Team or a Business subscription, you can turn off the check for updates by clearing the Automatically Check for Updates checkbox in the General settings. This will also disable the notification badge that appears on the Docker Dashboard.
To encourage developers to stay up to date, Docker Desktop displays a reminder two weeks after an update becomes available. You can dismiss this daily reminder by clicking Snooze. You can skip an update when a reminder appears by clicking the Skip this update option.
Docker Subscription Service Agreement
Beginning on August 31, 2021, you must agree to the Docker Subscription Service Agreement to continue using Docker Desktop. Read the Blog and the Docker subscription FAQs to learn more about the changes.
Click Download update When you are ready to download the update. This downloads the update in the background. After downloading the update, click Update and restart from the Docker menu. This installs the latest update and restarts Docker Desktop for the changes to take effect.
When Docker Desktop starts, it displays the Docker Subscription Service Agreement window. Read the information presented on the screen to understand how the changes impact you. Click the checkbox to indicate that you accept the updated terms and then click Accept to continue.
If you do not agree to the terms, the Docker Desktop application will close and you can no longer run Docker Desktop on your machine. You can choose to accept the terms at a later date by opening Docker Desktop.
Docker Desktop starts after you accept the terms.
Uninstall Docker Desktop
To uninstall Docker Desktop from your Mac:
- From the Docker menu, select Troubleshoot and then select Uninstall.
- Click Uninstall to confirm your selection.
Uninstalling Docker Desktop destroys Docker containers, images, volumes, and other Docker related data local to the machine, and removes the files generated by the application. Refer to the back up and restore data section to learn how to preserve important data before uninstalling.
Источник
Marcin PilЕ›niak
How to install Docker on Mac OS using brew?
What is Docker?
Docker is the next step on long IT containerization way. What does it mean? Years ago, you could run each application/process in particular container, that application couldn’t go outside the container which it was run. It was very safe but difficult to manage and not sharable. So you couldn’t easy share your container to other machine or to other developers to reuse for example by open source community.
So, that solution was a little bit complicated and worked only on Linux. Today we have Docker, which allows you to run containers on all operation systems. What is important, this tool is not only modern but also easy to manage and easy to share to others developers.
Other ways to install it
In this post, I want to show you how to install Docker by using brew which installation process I wrote last time. For me, it’s the easiest and safest way. But there are a few other possibilities to install it on Mac OS.
Docker.com – first method
First what you have to do is to go to Docker website and just download and run the .dmg file.
This is probably the easiest way, but unfortunately not the best. Using native install method you don’t have to install VirtualBox to run Linux, but sharing files between your Mac OS and systems in containers are really slowly. I can recommend that solution only if you want to test something or your project doesn’t use a framework with a lot of files.
Docker Toolbox – second method
It’s an app provided by Docker Company for Mac OS and Windows. The special feature in this toolbox is the requirement for VirtualBox, which will be a supervisor to run Linux. So, Docker is available as another machine in Docker environment. This toolbox contains also docker-compose (more below) and Kinematic, which allow you to manage your container by using GUI than a command line.
Install
I guess you have installed brew if not just follow this page and do everything that I’ve described.
If you are ready, open your terminal and type something like this:
If you have done it that you’ve received notice that docker-machine-driver-xhyve has to run as root , so you have to execute that commands:
Both commands will ask you for a password. Don’t worry to type it in a command line.
If everything goes ok then you can create your first docker machine, just type this command:
This command, as you suppose, creates a docker machine, using the xhyve driver.
—xhyve-experimental-nfs-share – this flag allows you to share each file in your /Users/ folder between Mac OS and Linux run on Docker.
Because you can have a lot docker machine, you can type this command in your terminal:
It registers a few variables, which allow you to use default docker machine without typing “default” each time.
Useful tools
Probably, you’ve noticed that with docker you installed also docker-machine and docker-compose . These tools are not required but they are the strength of docker.
docker-machine
This tool allows you to prepare a lot of docker machines on your Mac OS, so you can have a lot of containers on many Linux distributions. You can dump all available commands just by typing docker-machine —help but most likely you will use three of them:
I guess I don’t have to describe what exactly this commands do. It’s so obvious. One thing you need to know, if something goes wrong, just try to restart your docker machine.
docker-compose
The main goal of docker: you can write like this “one process = one container”, but each app requires a lot process it could be a PHP, HTTP server, some database etc. Of course, you can run containers for each process manually, which is not a big deal with 3 containers, but trust me it escalates very fast, so you need an easy tool to manage your container and to manage the dependencies because one container can require access to another container. For example, PHP app needs information from a database, but it doesn’t need access to HTTP server. Of course, and HTTP server requires access to PHP.
To work with docker-compose you need to create an YAML file called docker-composer.yml where you describe which container you want to create and how they are linked between each other.
That file can look like this:
As you can see, you are creating two containers, first, contains MySQL database and second one – a WordPress instance. This example is flattened, in normal case you should split WordPress instance to three another containers: PHP, HTTP server and one for WordPress files.
There is also created one volume, which contains files of MySQL database. This solution prevents loosing data when you turn off your Mac, or just reset docker-machine or this particular container.
If you want to read something more about parameters available in docker-compose file, you can just go to docker documentation.
docker-compose , as well as other tools, provides a lot of commands available from a terminal, the number one is:
This command runs all containers defined in your docker-compose file. If it is needed – rebuild and remove old unused containers.
How to use
Everything that you need is in the section above. You can manage of course each particular container directly from command line using command docker . But it’s just wasting a time.
Access by domain
Probably you want to access to your container by your web browser using some domains. You need to know what is IP of your docker machine and you can check it using command line just typing this:
You see IP and then use that IP in your /etc/hosts file.
Potential problems
Because you are trying to run Linux environment on Mac OS you can some across a lot strange problems if you want to use it in common work. Fortunately, you just need to follow some rules to enjoy work with docker.
Sharing files
If you installed a docker as described above you can share only files from your /Users/ folder. You can debug what is sharable directly on your docker machine, which can receive access directly from command line, like this:
Now, you are logged on your Linux and can browse to / and check is there /Users/ folder which contains files from your Mac OS. If you don’t see your files, just try to reinstall Docker and xhyve.
Speed of I/O process
Because docker needs transfer files between your Mac OS and Linux using the NFS it’s always more slowly then operation directly on your disk. So, if you want to boost up your application you have to remember to share only needed files. if you are backend develop you don’t share frontend javascript libraries, just put in into inside container.
Don’t forget to ignore cache and logs files!
Access via domain/IP
Restarting Mac OS or docker-machine sometimes restarts also IP of the docker machine. If you can’t connect to your docker just check the current IP using this command:
If it doesn’t work, you have to update domains in your /etc/hosts file.
Источник
A complete one-by-one guide to install Docker on your Mac OS using Homebrew
Beginner’s guide to install and run Docker on Mac OS
(update 2021–01–10)NOTE:
Some kind reader reported me that this seems not working for Mac with Apple silicon M1. I am sorry but I am not going to inspect in a short period. For M1 user, please look for other resources.
Configurations
System Version: macOS 10.14.3 (18D109)
Kernel Version: Darwin 18.2.0
Shell: zsh
Package manager: Homebrew
For short, the entire installation process is as follows.
Step-by-step Installation Process
Docker installation via Homebrew
Note that brew install docker and brew cask install docker is different. Some of the instructions about docker installation on Mac OS use the latter code that installs Docker as an Application, which you can see a good explanation.
⚠️ You can’t run Docker just after installing Docker. If you try, you’ll see:
This is because on macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it. (source)
Docker-Machine installation via Homebrew
⚠️ ️️ You can’t still create a machine because you don’t have VirtualBox. If you try, you’ll see:
So, download VirtualBox. You can only cask install (you can confirm this by running brew search virtualbox ).
VirtualBox installation via Homebrew
⚠️ It’s possible you’ll fail to install VirtualBox with an error message like this:
When you do fail, turn on System Preference and see if ‘ System software from developer “Oracle America, inc” was blocked from loading.’ If you see that message, click Allow button and try to install again. (Sadly when you still fail to install, Daniel Meechan will help you more.)
Successfully installed? Great!
Create a new virtual machine
Then, let’s create a machine. You can create a machine by docker-machine create (name) with —driver flag to specify a provide on which the machine is created on. (docker doc)
Run docker-machine ls and you’ll see your ‘default’ machine is now created.
Few more steps. As noted in the output of the docker-machine create command, run the following command to tell the Docker ‘which machine’ to execute docker command to.
And connect your shell to the new machine. Here I’m using zsh (Docker supports bash cmd powershell emacs , fish and SHELL can be OK).
Finally, let’s check that all installation process is achieved correctly!
When you finish playing around with Docker this time, don’t forget to stop the machine with this command. ( You can check the status docker-machine ls )
What we have done?
All the way long, we did it. What we did are the following things:
- installed Docker, Docker Machine, VirtualBox
- docker-machine create created a new Docker virtual machine (named ‘default’)
- docker-machine env switched your environment to your new VM (named ‘default’)
- eval use the docker client(your local computer/terminal) to create, load, and manage containers
- docker run Docker client (your terminal) created the Docker deamon
- pulled the first image ‘hello-world’
- The Docker deamon created a container, streamed out that output to the Docker client
- docker-machine stop shut down the virtual machine
Docker Machine CLI commands
Thank you all for reading! Hope this helps you a little.
Источник