Avoid the use of pit alpine guide

alpine, is the smallest Linux distribution a weight of only 5 MB. It also has basic linux tool and a good package manager APK. APK very stable, a significant number of packages. Due to small size, very popular in the container, but also use a lot of the pit, most probably our ignorance of it.

Pit 1: Download Slow

解决:
echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main" > /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/community" >> /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/edge/testing" >> /etc/apk/repositories

Pit 2: Can not find the package

Solution: Search https://pkgs.alpinelinux.org/packages, adding designated "Branch" and "Repository" source to / etc / apk / repositories, you can apk add

 

Pit 3: installation fails

ERROR: https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/community: Bad file descriptor
WARNING: Ignoring APKINDEX.79f426e4.tar.gz: Bad file descriptor
ERROR: unsatisfiable constraints:
  openssh (missing):
    required by: world[openssh]

solve:

apk add openssh --no-cache # plus --no-cache, further, it can reduce the volume of the mirror

 

Pit 4: Mirror bulky package you want to delete no longer in use

apk add add -t parameter 

-t, NAME, called Virtual Packages The INSTEAD All of Adding to 'World', A new new Create Virtual Package The listed Dependencies and with that to the Add 'World'; The
Actions of Easily The Command are reverted Deleting The Virtual Package by
this means when you install the package, these packages are not added to the overall package. This change can be easily rolled back / Remove. So, if I need gcc to compile the program, but once the program is compiled, I will not need the gcc.

I can install in the virtual package gcc and other necessary packages, and you can delete all the dependencies, and delete the virtual package name. The following is an example of usage

the Add - Virtual mypacks gcc vim APK
APK del mypacks
use the first command to install all of the 18 packages will be deleted the next command.

Note: The same parameters for all installation packages before -t will cover all best not to use -t dynamic link library, or to ensure that this parameter is not repeated.

 

Pit 5: Time is not synchronized

echo "Asia/Shanghai" > /etc/timezone
apk add –no-cache tzdata
TZ=Asia/Shanghai
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

Pit 6: user (group) and is not compatible with the host

solve:

addgroup -g 1200 -S www \
     && adduser -u 1200 -D -S -G www www

Pit 7: incompatible glibc

solve:

Use the latest stable version of alpine,

# Install the build environment
apk add --virtual .build-base --no-cache 
autoconf \
automake \
g
++ \
make \

linux-headers \
bsd-compat-headers 
 

 

Guess you like

Origin www.cnblogs.com/sunsky303/p/11548343.html