![Docker and Kubernetes for Java Developers](https://wfqqreader-1252317822.image.myqcloud.com/cover/786/36700786/b_36700786.jpg)
Installing on macOS
To get the native Docker version for your Mac, head to the http://www.docker.com and then the Get Docker macOS section. Docker for Mac is a standard, native dmg package you can mount. You will find just a single application inside the package:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/339595d0-962b-49a3-86ef-a43e791db97d.png?sign=1738851799-ouzeYG1mYtyAXyo7bEsT2qkfEQnWezPb-0-a8a84f0fa71a581e3f921104d544884a)
Now just move the Docker.app into your Applications folder, and you are all set. Couldn't be easier. If you run Docker, it will sit as a small whale icon in your macOS menu. The icon will animate during the Docker startup process and stabilize after it finishes:
- If you now click the icon, it will give you a handy menu with the Docker status and some additional options:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/9f86b82d-9558-4948-bfce-ccd93ba41d5b.png?sign=1738851799-S2GNda2CI6UX2UuifqE1YwRNAT5n6Jg1-0-90cd441b899083067712b8ac4e916864)
- Docker for Mac has an auto-update capability, which is great for keeping your installation up to date. The first Preferences... pane gives you the possibility to automatically check for updates; it's marked by default:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/2675b3c2-28d2-42bc-94b3-38759f89162c.png?sign=1738851799-uYAJjEvDqsz3UFQUeXWBtMLuJN1yso4s-0-e6fdc57c6f9de79491cd2d23a2ee7cbe)
- If you are a brave soul, you can also switch to the beta channel for getting updates. This way you can always have the latest and greatest Docker features, with the risk of decreased stability, as is always the case with beta software. Also take note that switching to the beta channel will uninstall your current stable version of Docker and destroy all of your settings and containers. Docker will warn you about this, to make sure you really want to do it:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/b20ad946-90a6-4062-8894-0119395944fd.png?sign=1738851799-myC2QUfevXJqV2JfxeBSXd2z9hZ8Hqmt-0-feefbd5ba0831e21ec1f65d695c3b5bb)
- The File Sharing pane of the Preferences... will give you an option to mark macOS directories on your machine to be bind mounted into Docker containers you are going to run later. We will explain mounting directories in detail later on in the book. For the time being, let's just have the default set of selected directories:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/5892d02d-9ffb-4d93-a08a-aa4c0df6bb31.png?sign=1738851799-fFFiwmGAI8tX5Zf60TjeZit3ynlbnXkV-0-7ce075d3745390f094e1f17fd4f352ec)
- The Advanced pane has some options to adjust the resources of your computer that will be available for Docker, it will be the number of processors and memory amount. The default settings are usually a good start if you begin with Docker on macOS:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/8ff2fe05-0753-4e54-8128-1a753a4f4e29.png?sign=1738851799-LrqFw20stVruDGm0uncnHovAA8eBwhqw-0-96b606df7a3a9562838799fff7615335)
- The Proxies pane gives you the possibility to setup a proxy, if you need it on your machine. You can opt for using system or manual settings, as you can see in the following screenshot:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/f498ac90-4d82-41ee-a274-f54b87684fae.png?sign=1738851799-p9VdEnw9Hi7EBroLfOIcX06JNNNUGNpm-0-c451d8bc367aa4372045a550a967b158)
- On the next page, you can edit some Docker daemon settings. This will include adding registries and registry mirrors. Docker will use them when pulling the image. The Advanced tab contains a text field, in which you can enter the JSON text containing the daemon config:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/9f9f4392-602d-4e18-badd-52714bb3ca21.png?sign=1738851799-z6ObFmGLuo2tQxwoEviD3NnfNCdlySUd-0-37f43c103e72b7e9c34145675bcbfd2f)
- In the Daemon pane, you can also turn off Docker Experimental features. For some time now, Experimental features have been enabled by default. From time to time, a new version of Docker comes with new Experimental features. At the time of writing this book, they will include, for example, Checkpoint & Restore (a feature that allows you to freeze a running container by checkpointing it), Docker graph driver plugins (to use an external/out-of-process graph driver for use with the Docker engine as an alternative to using the built-in storage drivers), and some others. It's always interesting to see what new features are included in the new version of Docker. Clicking the link in the Daemon page will take you to the GitHub page which lists and explains all the new experimental features.
- The last Preferences... pane is the Reset. If you find that your Docker won't start or behaves badly, you can try to reset the Docker installation to the factory defaults:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/bd8b6e0f-a89e-4526-a1a2-a10884d69cab.png?sign=1738851799-NCKFiesPTZX77NsTAsBJ3YGEjt2hkxFN-0-2a3f5242ab5e94deb1543176af692add)
You should be warned though, that resetting Docker to the factory state will also remove all downloaded images and containers you may have on your machine. If you have images that have not been pushed anywhere yet, having a backup first is always a good idea.
The Open Kitematic in the Docker menu is a handy shortcut to open the Kitematic application we have mentioned earlier. It's a desktop utility for using Docker on Windows and Mac OS X. If you do not have Kitematic installed already, Docker will give you a link with the installation package:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/a01d9571-242b-4649-a033-48476c8ba24c.png?sign=1738851799-kONWe6GrRDPBmRBYInwhatoGtXcWgWdu-0-1bcc62c680d3c3b9c88c42e83ab2625b)
- If you run Kitematic, it will present you the Docker Hub login screen first. You can now Sign up to the Docker Hub and then log in providing your username and password:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/0dfcc326-4c8e-4807-a9e5-939923d02a72.png?sign=1738851799-eYoUFE5LqN2KUlLogjl5XJTSuaWXvo7Q-0-5abc221f09010135551b18c8b900c0e3)
Clicking on Skip For Now will take you to the images list without logging into the Docker Hub. Let's test our installation by pulling and running an image. Let's search for hello-java-world, as seen on the following screenshot:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/479e5852-c763-49a9-ac7f-6943482e4803.png?sign=1738851799-5DtZrhuVWR7dH61CqMIniVdHExQjyvVo-0-855210e4c73c69aafb66ec8cae0688d7)
After pulling the image from the registry, start it. Kitematic will present the running Container logs, which will be the famous hello world message, coming from a containerized Java application:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/1aab5a59-1a4c-4302-9330-f4db6fc3a25d.png?sign=1738851799-V2DquBwnjOPaK69Ll69R1ZUPQEA6mbPB-0-e0047c1e122d825eff798e8391e8c356)
That's it for running the container in Kitematic. Let's try to do the same from the shell. Execute the following in the terminal:
$ docker run milkyway/java-hello-world
As a result, you will see the same greeting, coming from a containerized Java application, this time in the macOS terminal:
![](https://epubservercos.yuewen.com/C768D0/19470404601622406/epubprivate/OEBPS/Images/bd64e718-f496-4b62-aaf3-2ef4597df9f3.jpg?sign=1738851799-9Uu2cdB6peAQoVG9bXTvc7k5jRgaSHXn-0-d7816f0b47764cfba137755faddb0a6c)
That's it, we have a native Docker up and running on our macOS. Let's install it on Linux, as well.