In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use Docker on M1". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Docker on M1.
I. official publicity 1.1 official propaganda version
Previously, Docker can only run on the X86 architecture of Intel chips. Docker has officially supported Apple M1 chips, while M1 chips are based on ARM architecture, so Docker is really too powerful to adapt to Apple's latest system in just a few months!
Isn't that why Guan Xuan Docker handsome guy wants to chase M1 girl?
Wukong went to the official website to take a look at the official version released in 2021-04-15: Docker Desktop 3.3.1, and it can be downloaded directly.
Official website address: https://docs.docker.com/docker-for-mac/apple-silicon/
This Desktop contains many features:
Docker Engine
Docker CLI client
Docker Compose
Notary
Kubernetes
Credential Helper
In addition, there are some conditions that need to be met to run Docker on M1.
1.2 requirements
Because M1 is more avant-garde, you need to install Rosetta software for compatibility.
Rosetta must be installed because some binaries are still Darwin / AMD64. To install Rosetta 2 manually from the command line, run the following command:
Softwareupdate-install-rosetta
Docker officials are expected to fix this issue in a future release.
1.3 running-in
There are still many areas where Docker and M1 need to run in:
Not all images can be used in M1's ARM64 architecture, such as mysql images are not suitable. However, this problem can be resolved by using mariadb mirroring.
I tried, but there was no suitable mysql image.
Because QEMU sometimes fails to run containers, running Intel-based containers on Apple Silicon computers can cause crashes. We recommend that you run the ARM64 container on an Apple Silicon computer. These containers are also faster and use less memory than Intel-based containers.
Ping's connection from inside the container to Internet is not working properly. To test the network, we recommend using curl or wget.
When the TCP stream is half-closed, users may sometimes encounter data loss.
Hand in hand 2.1 left hand to right hand
Previously, Docker was installed from the command line in the Linux environment, but it is much more convenient to have a client on Mac. It is very convenient to install the Mac version of Docker, and the downloaded file is called Docker.dmg. After double-clicking the file, the following interface pops up, and drag the Docker.app icon to the right Appliactions, just like pulling the right hand with the left hand.
Docker handsome guy successfully held hands with M1.
After the installation is complete, find Docker in the application and double-click to open it.
Then you can see that Docker is displayed in the menu bar.
2.2 start the container
The open interface prompts that no container is running, and the client prompts you to execute the following command to start a new container.
Docker run-d-p 80:80 docker/getting-started
We copy the command to the console and run it, as shown in the following figure:
Then we will check whether the container is created and started successfully under check. Use the following command to view the running status of the docker container.
Docker ps
We can also check the container status through the Docker client: the container is running and the corresponding port number is 80. As shown in the following figure:
In addition, we can also see which images have been downloaded. As shown in the following figure, there is currently an image: docker/getting-started.
2.3 Intel & Apple
When we open the activity monitor, we can see that the docker processes open have both Apple architecture and Intel architecture. For example, desktop UI uses Intel architecture, but the Apple architecture used by Docker core applications indicates that although there is a partial use of Intel architecture, the core is still Apple architecture, which does not affect the use.
Let's take a look at the memory usage. 12 processes occupy a total of 430 M of memory, indicating that the memory occupied is not high and the performance is OK.
Third, warm man
Docker client also has a series of user-friendly configurations, a high-quality warm man. Let's take a look at the configuration.
3.1 General preference settings
Docker client, there are many user-friendly general settings. As shown in the following figure:
Automatically check for updates: by default, Docker Desktop is configured to automatically check for newer versions. If you have installed Docker Desktop as a member of your organization, you may not be able to update Docker Desktop yourself. In this case, upgrade your existing organization to a team plan, and then clear this check box to disable automatic checking for updates.
Start Docker Desktop when logging in: start Docker Desktop automatically when you open a session.
Include VM in Time Machine backup: select this option to back up the Docker Desktop virtual machine. This option is not checked by default.
Use gRPC FUSE for file sharing: clear this check box to use legacy osxfs file sharing instead.
Send usage statistics: Docker Desktop sends diagnostics, crash reports, and usage data. This information can help Docker improve and troubleshoot its application.
Show Weekly Tips: displays useful suggestions for using Docker.
Open the Docker Desktop dashboard at startup: automatically open the dashboard when you start Docker Desktop.
3.2 Advanced configuration of resources
There are also some advanced configurations about resources that are also very powerful, let's take a look.
CPU: by default, Docker Desktop is set to use half the number of processors available on the host. To improve processing power, set it to a higher number.
Memory: by default, Docker Desktop is set to use 2GB runtime memory, which is allocated from the total available memory on Mac. To increase the RAM, set it to a larger number, and if you want to reduce it, lower the number.
Swap: configure the size of the swap file as needed, with a default value of 1 GB.
Disk image size: specifies the size of the disk image.
Disk image location: specify the container of the Linux volume and the storage location of the image.
3.3 K8S
It's so cool that Docker Desktop directly supports kubernets (K8S).
Docker Desktop includes a stand-alone Kubernetes server that can run on Mac, so you can test the workload of deploying Docker on Kubernetes. To enable Kubernetes support and install a stand-alone instance of Kubernetes running as a Docker container, select Enable Kubernetes.
There are many very useful features, which will not be introduced here. If you are interested, you can check them on the official website.
Docker is definitely a high-quality warm man for M1! It's a hammer! ?
Fourth, appointment
After talking about so many advantages of Docker, M1 is finally willing to fall in love with Docker, and their first dating activity is actual Redis.
4.1 download Redis image
First, let Docker download a Redis image to try:
Sudo docker pull redis
We can check whether the image has been downloaded successfully through the Docker client, as shown in the following figure. You can also view it through the command docker ps.
4.2 start Redis
Start redis
Docker run-d-p 6379 6379 redis
4.3 Connect redisdocker exec-it redis-cli
You need to find the redis container id through docker ps. The redis container id running on my machine is 17c. It can be abbreviated in the command, as long as the container is recognized.
After the connection is successful, you will go to the redis command line.
4.4 Test Redis
Set astat100 and return OK
Set a 100
Gets the value of an and returns "100"
Get a
It shows that docker runs Redis perfectly on M1.
In addition, I want to use Elasticsearch and Kibana in my open source project, but there is no suitable image, which is very uncomfortable.
At this point, I believe you have a deeper understanding of "how to use Docker on M1". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.