For image download, domain name resolution and time synchronization, please click Alibaba open source mirror station
Docker Desktop is the most popular developer tool. Docker announced on August 31 that it has changed the user agreement of Docker Desktop, which will continue to be free for individual developers, but has adopted a charging strategy for commercial developers. Recently, many students came to ask me related questions, and I also made an explanation on this
As for the payment process for Docker Desktop, we have communicated with the group procurement team, but the License authorization of Docker company is somewhat complex. If the Pro version is purchased, each developer needs to pay for it, and batch procurement is not supported. The Business version supports batch purchase, but we don't need it. We are still following up on other feasibility, and we will continue to communicate with you.
If you only need to run the K8s environment, using Alibaba cloud container service ACK is the most recommended solution. There is no one: -)
If you need a free local development environment and good hands-on ability, you can refer to the content of this article
Introduction to Minikube
Minikube is a popular open source Kubernetes development environment in the community. In order to help domestic students use minicube for daily development more efficiently and barrier free, minikube can support alicloud's mirror site as a container image. Furthermore, in the official minikube of v1.24.0, a scheme submitted by Alibaba cloud team has been merged, which can perfectly support the rich addon components of minikube!
Minikube can create Kubernetes running environment in MacOS/Windows/Linux environment with the help of different driver implementations.
This article will use the hyperkit driver to create a virtual machine on MacOS to configure the Minikube environment.
Uninstall Docker Desktop first
Open the preference - > troubleshoot page and click Uninstall
Install and configure Minikube and corresponding Docker environment
Install hyperkit, Minikube, and Docker command line tools (Note: runtime environment is not included)
$ brew install hyperkit $ brew install minikube $ brew install docker
Experience Kubernetes under Minikube
The simplest way to create a Kubernetes environment is to use the following command
minikube start --image-mirror-country='cn'
The minicube start command provides many configuration parameters,
Common configuration parameters are as follows
- --cpus=2: allocate CPU cores for minicube virtual machine
- --memory=2048mb: number of memory allocated for minicube virtual machine
- --Registry mirror = * * *: to improve the stability of pulling Docker Hub images, you can configure image acceleration for Docker daemon. Refer to Alicloud image service Related accelerator configuration
- --Kubernetes version = * * *: the version of kubernetes that the minicube virtual machine will use. For example, create a minicube environment and adjust the default resource configuration
Create minicube runtime environment
$ minikube start --image-mirror-country='cn' Darwin 11.6 Upper minikube v1.24.0 ✨ Automatic selection hyperkit drive ✅ Using mirror repository registry.cn-hangzhou.aliyuncs.com/google_containers Starting control plane node minikube in cluster minikube Creating hyperkit VM (CPUs=2, Memory=4000MB, Disk=20000MB) ... Is Docker 20.10.8 Medium preparation Kubernetes v1.22.3... ▪ Generating certificates and keys ... ▪ Booting up control plane ... ▪ Configuring RBAC rules ... Verifying Kubernetes components... ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5 Enabled addons: storage-provisioner, default-storageclass Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Open the Kubernetes console
$ minikube dashboard Opening dashboard ... ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-scraper:v1.0.7 ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/dashboard:v2.3.1 Validating dashboard Operation ... Launching proxy ... Validating proxy Health status ... Opening http://127.0.0.1:49996/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
Minikube also provides rich Addon components. For example, we can monitor the resource usage of Pod by opening the metrics server component.
$ minikube addons enable metrics-server
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.4.2 start-up 'metrics-server' plug-in unit
If you need to use progress, you can refer to https://minikube.sigs.k8s.io/... To learn to use
For more information on the use of Minikube, please refer to https://minikube.sigs.k8s.io/
Create a Minikube that does not run Kubernetes
For developers who do not need to use Kubernetes, Minikube also provides support for Minikube environments that do not run Kubernetes after v1.24. It can save more resources.
$ minikube start --no-kubernetes Darwin 11.6 Upper minikube v1.24.0 ▪ MINIKUBE_ACTIVE_DOCKERD=minikube ✨ Automatic selection hyperkit drive Starting minikube without Kubernetes minikube in cluster minikube Creating hyperkit VM (CPUs=2, Memory=4000MB, Disk=20000MB) ... Done! minikube is ready without Kubernetes! Done! minikube is ready without Kubernetes! ╭───────────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Things to try without Kubernetes ... │ │ │ │ - "minikube ssh" to SSH into minikube's node. │ │ - "minikube docker-env" to point your docker-cli to the docker inside minikube. │ │ - "minikube image" to build images without docker. │ │ │ ╰───────────────────────────────────────────────────────────────────────────────────────╯
Configure Docker environment
First, configure the environment variable of Docker command line tool
$ eval $(minikube docker-env)
Then you can play happily with the familiar Docker command-line tool
$ docker ps $ docker images
Create a Dockerfile as follows
FROM nginx RUN echo 'Hello World!' > /usr/share/nginx/html/index.html
Build and run images
$ docker build -t test . $ docker run -d -p 8080:80 test
$ curl $(minikube ip):8080 Hello World!
Note: the host port exposed by docker is on the Minikube virtual machine, so you need to use minikube ip to obtain the IP of the virtual machine. Docker Desktop further optimizes the developer experience so that the exposed endpoints can be directly mapped to the local.
How do we mount local file volumes into the Docker container? This is a little windy. First of all, we need to know that the Docker environment is running on the Virtual Machine of Virtual Machine. We need to mount the local volume to the Minikube Virtual Machine first.
$ mkdir test $ echo 'Just for test!' > test/test.txt $ minikube mount ./test:/test
Then, we can mount the volume on the Minikube virtual machine in the Docker image and access it
$ docker run --rm -it -v /test:/inside busybox cat /inside/test.txt Just for test!
Note: Docker Desktop also provides a good user experience in this scenario, allowing users to ignore the complexity of the underlying implementation.
Developers with strong hands-on ability can develop local containers and Kubernetes without the help of Docker Desktop. Alibaba cloud team has also provided good network access experience for domestic developers. If you have any questions, you can mention Issue on Github
However, for ordinary developers, Docker Desktop has many optimizations in the development experience. The price of $5 per month for Pro version, that is, a cup of Starbucks coffee, can save some tossing time.
Original source: https://developer.aliyun.com/...