Mastering Docker Enterprise
上QQ阅读APP看书,第一时间看更新

Installing Docker on a local workstation

We will containerize our PoC application on a local workstation; this typically happens on a developer's desktop. These days, most application developers are using either macOS or Windows 10. So, Docker has created a free product based on the Docker Engine-Community called Docker Desktop. Docker Desktop is designed to make it very easy to install Docker Engine-Community with Kubernetes on recent versions of macOS and Windows 10 professional. The reason for using Windows Professional is due to Docker's use of Hyper-V on Windows, and Hyper-V is only available on Windows Professional and higher. The Docker Desktop install is available here: https://www.docker.com/products/docker-desktop

If you are using an older version of Windows, you are going to want to use the Docker Toolbox that is available here: https://docs.docker.com/toolbox/overview/. The toolbox is an old-school way of installing your own virtualizer, in this case VirtualBox, onto your Windows desktop and then running Docker in Linux VMs. Behind the scenes, all of these products use a very stripped-down Linux kernel to run the latest version of Docker. This image is called MobyLinuxVM and this same image runs on Hyperkit (macOS) and Hyper-V (Windows 10 Pro+) and in VirtualBox using Docker Toolbox (Window 7 and 8).

If you are running a Linux distribution on your developer desktop, the installation process is a little bit more manual. First, you need to install the Docker Engine: https://docs.docker.com/install/linux/docker-ce/ubuntu/. This link is for the Ubuntu distribution, but there are others available, as you will see in the left-hand navigation menu. After you've installed the Docker Engine on your Linux box, you will also need to install docker-compose separately. Detailed instructions can be found by following this link: https://docs.docker.com/compose/install/#install-compose.

If you are planning to containerize a Windows application, you will need to run Windows containers. The Windows container option is only available on Windows hosted machines, including Docker Desktop for Windows or Windows Server 2016+. Since Docker Desktop for Windows supports both Linux and Windows containers, you will have to choose the Windows container option shown in Figure 11. This menu is accessed by right-clicking the Docker whale (Moby) in the Windows system tray. If the whale is not there, it means that Docker is not running. Now, open your Windows Start menu and type in Docker for Windows, hit Enter to select and to start Docker up. Please note that it may take 1 to 2 minutes for Docker to start. You may have also noticed the Kubernetes menu item in the context menu. This is where you would go to enable Kubernetes. You won't need it yet, but it would'nt hurt to enable it.

Figure 11 shows the Docker Desktop Context menu. Right-click the Docker whale icon in the Windows system tray to access it:

Figure 11: Docker Desktop Context Menu
When changing between Linux containers and Windows containers, you are connecting to a different Docker Engine on your local machine and each engine has a its own location/file system to store the Docker image cache. So when switching from Linux to Windows, your local Linux images wont be available until you switch back. Also, some Docker updates may cause a loss of local images. So, it is a good idea to push local images to a remote repository (like Docker Hub— https://hub.docker.com/) before switching container types or update Docker.