what is docker alpine

藏色散人
Release: 2021-12-09 15:55:33
Original
7894 people have browsed it

docker alpine is a kind of image. The Alpine Docker image inherits the advantages of the Alpine Linux distribution. Compared with other Docker images, its capacity is very small, only about 5MB, and it has very friendly package management. mechanism.

what is docker alpine

The operating environment of this article: ubuntu 18.04 system, Docker version 20.10.11, Dell G3 computer.

What is docker alpine?

Alpine operating system is a security-oriented lightweight Linux distribution. It is different from ordinary Linux distributions. Alpine uses musl libc and busybox to reduce the system size and runtime resource consumption. However, its functions are much more complete than busybox, so it is increasingly favored by the open source community. While maintaining weight, Alpine also provides its own package management tool apk. You can query package information through the https://pkgs.alpinelinux.org/packages website, or you can directly query and install various software through the apk command.

Alpine is a Linux distribution maintained by a non-commercial organization and supports a wide range of scenarios. It is specially optimized for experienced/heavy Linux users, focusing on security, performance and resource efficiency. Alpine images can be applied to more common scenarios and are an excellent basic system/environment suitable for production.

The Alpine Docker image also inherits these advantages of the Alpine Linux distribution. Compared with other Docker images, its capacity is very small, only about 5 MB (compared to nearly 200 MB for Ubuntu series images), and it has a very friendly package management mechanism. The official image is from the docker-alpine project.

Currently, Docker officials have begun to recommend using Alpine to replace the previous Ubuntu as the basic mirror environment. This brings several benefits. Including accelerated image download speed, improved image security, more convenient switching between hosts, and occupying less disk space.

The following table is a size comparison of official images:

REPOSITORY TAG IMAGE ID VIRTUAL SIZE alpine latest 4e38e38c8ce0 4.799 MB debian latest 4d6ce913b130 84.98 MB ubuntu latest b39b81afc8ca 188.3 MB centos latest 8efe422e6104 210 MB
Copy after login

Get and use the official image

Since the image is very small, The download time is often very short. Readers can directly use the docker run command to directly run an Alpine container and specify the Linux command to run, for example:

$ docker run alpine echo '123' 123
Copy after login

Migrate to Alpine base image

Currently, most Docker official images already support Alpine as a base image and can be easily migrated.

For example:

ubuntu/debian -> alpine python:3 -> python:3-alpine ruby:2.6 -> ruby:2.6-alpine
Copy after login

In addition, if you use the Alpine image to replace the Ubuntu base image, you need to use the apk package manager to replace the apt tool when installing the software package, such as

$ apk add --no-cache 
Copy after login

Alpine The name of the software installation package may be different from other distributions. You can search and determine the installation package name on the https://pkgs.alpinelinux.org/packages website. If the required installation package is not in the main index, but is in the test or community index. Then you can use these installation packages as follows.

$ echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories $ apk --update add --no-cache 
Copy after login

Since accessing the apk warehouse in China is slow, it is recommended to replace the warehouse address with the domestic mirror before using the apk.

RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \ && apk add --no-cache 
Copy after login

Recommended learning: "Docker Video Tutorial"

The above is the detailed content of what is docker alpine. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!