The Alpine operating system is a security-oriented lightweight Linux distribution. It is different from the usual Linux distributions. Alpine uses musl libc and busybox to reduce the size of the system and the consumption of runtime resources. But the function is more complete than busybox, so it is more and more favored by the open source community. While staying thin, Alpine also provides its own package management tool apk. You can query package information on the https://pkgs.alpinelinux.org/packages website, or you can directly query and install various software through the apk command.
1.Install alpine under docker
$ docker pull alpine
$ docker run -it -d --name myalpine alpine
–name myalpine represents the name of the container
The last alpine means mirroring
$ Means to execute the command in the terminal
You can use the command:
$ docer stop myalpine
Stop a container
The command to start a container is as follows:
$ docker start myalpine
Whether to stop or start the container, you can use the name of the container or the ID of the container
$ docker exec -it alpine_linux sh
Note that the default shell of the alpine operating system does not use bash, but uses sh, so when entering the container Using sh instead of bash, the command is as follows:
$ docker exec -it alpine_linux sh
In this way, the environment of the alpine linux system under docker is ready, which can be said to be more convenient.
2. Update domestic sources
By default, alpine linux is a streamlined environment, no extra toolkits are installed, so the system is smaller, and users can You need to install the required toolkit yourself.
Alpine linux provides apk package management commands, and we can install the tools we need by ourselves. The official software source is slow by default, so you can use the domestic mirror source.
Using the domestic Alibaba Cloud source, the content of the file is:
https://mirrors.aliyun.com/alpine/v3.13/main/
https://mirrors.aliyun.com/alpine/v3.13/community/
Using the source of the University of Science and Technology of China, the content of the file is:
https://mirrors.ustc.edu.cn/alpine/v3.13/main/
https://mirrors.ustc.edu.cn/alpine/v3.13/community/
The software source file of alpine is /etc/apk/repositories
It can be modified to any domestic mirror source above.
3. Use of apk package management commands
The apk package management command is very simple to use, do not know what command to use, you can check the help
$ apk -h
apk-tools 2.12.5, compiled for x86_64.
usage: apk [<OPTIONS>...] COMMAND [<ARGUMENTS>...]
Package installation and removal:
add Add packages to WORLD and commit changes
del Remove packages from WORLD and commit changes
System maintenance:
fix Fix, reinstall or upgrade packages without modifying WORLD
update Update repository indexes
upgrade Install upgrades available from repositories
cache Manage the local package cache
Querying package information:
info Give detailed information about packages or repositories
list List packages matching a pattern or other criteria
dot Render dependencies as graphviz graphs
policy Show repository policy for packages
Repository maintenance:
index Create repository index file from packages
fetch Download packages from global repositories to a local directory
manifest Show checksums of package contents
verify Verify package integrity and signature
Miscellaneous:
audit Audit system for changes
stats Show statistics about repositories and installations
version Compare package versions or perform tests on version strings
This apk has coffee making abilities.
For more information: man 8 apk
The help command lists the common commands of apk
For example, install the curl package
$ apk add curl
Remove the installed curl package
$ apk del curl
Query curl-related software packages
$ apk search curl