“Alpine”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的24个中间版本)
第1行: 第1行:
 +
=NOTE=
  
 +
一般一个软件官方用什么os作容器就用他,不一定是alpine才是最好的 例如 mysql  python就可能不是
 +
https://www.armbian.com/
 +
 +
[https://cloud.tencent.com/developer/article/1632733 不要轻易使用 Alpine 镜像来构建 Docker 镜像,有坑!]
 +
 +
[https://www.infoq.cn/article/VODLe9FsiBkQdlcxJZZj 用Alpine会让Python Docker的构建慢50倍]
 +
 +
=see also=
 +
[[Alpine 修改docker的时区及安装telnet]]
 +
 +
=alpine  lnmp 也为docker准备 =
 +
[https://www.jianshu.com/p/41ac6157c5fc alpine apk  lNMP安装部署]
 +
 +
[https://wiki.alpinelinux.org/wiki/Production_LAMP_system:_Lighttpd_%2B_PHP_%2B_MySQL#Installation Production LAMP system: Lighttpd + PHP + MySQL]
 +
 +
[https://wiki.alpinelinux.org/wiki/Nginx_with_PHP#Nginx_with_PHP7 alpine lnmp]
 +
 +
 +
[https://www.cyberciti.biz/faq/how-to-install-php-7-fpm-on-alpine-linux/ How to install PHP 7 fpm on Alpine Linux]
  
 
=pre=
 
=pre=
 
占用内存仅仅 37M ,非常的小巧。适合用在树莓派或者其他低内存设备上。
 
占用内存仅仅 37M ,非常的小巧。适合用在树莓派或者其他低内存设备上。
 
[https://liyin.date/2017/03/18/alpine-linux-setup/index.html Alpine Linux 折腾记]
 
[https://liyin.date/2017/03/18/alpine-linux-setup/index.html Alpine Linux 折腾记]
 +
 +
=修改 源 为cst 中国标准时间=
 +
<pre>
 +
#修改源
 +
cat  /etc/apk/repositories
 +
 +
 +
echo 'https://mirrors.ustc.edu.cn/alpine/v3.14/main
 +
https://mirrors.ustc.edu.cn/alpine/v3.14/community'>/etc/apk/repositories
 +
 +
 +
 +
http://mirrors.aliyun.com/alpine/v3.12/main
 +
http://mirrors.aliyun.com/alpine/v3.12/community
 +
 +
echo 'http://mirrors.aliyun.com/alpine/v3.12/main
 +
http://mirrors.aliyun.com/alpine/v3.12/community' >/etc/apk/repositories
 +
 +
apk add --update nodejs npm
 +
 +
#RUN 表明 这是在容器里面的
 +
RUN apk add -U tzdata
 +
 +
#设置时区
 +
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 +
  && echo 'Asia/Shanghai' >/etc/timezone
 +
</pre>
 +
 
=download =
 
=download =
  
第52行: 第100行:
 
a. 编辑 /etc/apk/repositories
 
a. 编辑 /etc/apk/repositories
 
b. 将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com ; 保存退出即可
 
b. 将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com ; 保存退出即可
 +
 +
非交互
 +
 +
 +
echo 'http://mirrors.aliyun.com/alpine/v3.14/main
 +
http://mirrors.aliyun.com/alpine/v3.14/community' >/etc/apk/repositories
 +
 +
apk add --update nodejs npm
 +
  
 
  cat  /etc/apk/repositories
 
  cat  /etc/apk/repositories
第149行: 第206行:
 
http://mirrors.aliyun.com/alpine/v3.10/main
 
http://mirrors.aliyun.com/alpine/v3.10/main
 
http://mirrors.aliyun.com/alpine/v3.10/community
 
http://mirrors.aliyun.com/alpine/v3.10/community
 +
 +
echo 'http://mirrors.aliyun.com/alpine/v3.18/main
 +
http://mirrors.aliyun.com/alpine/v3.18/community' >/etc/apk/repositories
 +
apk add openjdk8
 +
apk add  maven
 +
 +
  
  
第182行: 第246行:
 
more-itertools requires Python '>=3.5' but the running Python is 2.7.16
 
more-itertools requires Python '>=3.5' but the running Python is 2.7.16
  
 +
</pre>
 +
==nodejs yarn etc==
 +
<pre>
 +
#换源 然后
 +
apk add  --no-cache  nodejs yarn python
 
</pre>
 
</pre>
  
 
https://wiki.alpinelinux.org/wiki/Docker
 
https://wiki.alpinelinux.org/wiki/Docker
 +
 +
=alpine docker php=
 +
github 有个php-worker 搞了一关的 可以参考
 +
 +
[https://blog.csdn.net/liyyzz33/article/details/97265262    Alpine安装php各种扩展]
 +
 +
[https://blog.csdn.net/u010953609/article/details/89309712  Dockerfile 学习:Docker Alpine PHP 安装扩展]
 +
 +
[https://blog.csdn.net/qw_xingzhe/article/details/80161109  docker官方alpine/php镜像下安装php扩展]
 +
 +
[http://www.zzfly.net/alpine-linux-php-mysql/ Alpine Linux 初上手与安装 PHP7 / MySQL 环境]
  
 
=trouble shooting=
 
=trouble shooting=
第225行: 第305行:
 
apk  add rsync
 
apk  add rsync
 
</pre>
 
</pre>
 +
 +
=install golnag=
 +
<pre>
 +
 +
#1.16 的,新的可能要下载的安装方式
 +
apk add --no-cache git make musl-dev go
 +
</pre>
 +
https://stackoverflow.com/questions/52056387/how-to-install-go-in-alpine-linux
 +
=install nginx =
 +
<pre>
 +
nstall the prerequisites:
 +
 +
    sudo apk add openssl curl ca-certificates
 +
 +
To set up the apk repository for stable nginx packages, run the following command:
 +
 +
    printf "%s%s%s%s\n" \
 +
        "@nginx " \
 +
        "http://nginx.org/packages/alpine/v" \
 +
        `egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release` \
 +
        "/main" \
 +
        | sudo tee -a /etc/apk/repositories
 +
 +
Next, import an official nginx signing key so apk could verify the packages authenticity. Fetch the key:
 +
 +
    curl -o /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
 +
 +
Verify that downloaded file contains the proper key:
 +
 +
    openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout
 +
 +
The output should contain the following modulus:
 +
 +
    Public-Key: (2048 bit)
 +
    Modulus:
 +
        00:fe:14:f6:0a:1a:b8:86:19:fe:cd:ab:02:9f:58:
 +
        2f:37:70:15:74:d6:06:9b:81:55:90:99:96:cc:70:
 +
        5c:de:5b:e8:4c:b2:0c:47:5b:a8:a2:98:3d:11:b1:
 +
        f6:7d:a0:46:df:24:23:c6:d0:24:52:67:ba:69:ab:
 +
        9a:4a:6a:66:2c:db:e1:09:f1:0d:b2:b0:e1:47:1f:
 +
        0a:46:ac:0d:82:f3:3c:8d:02:ce:08:43:19:d9:64:
 +
        86:c4:4e:07:12:c0:5b:43:ba:7d:17:8a:a3:f0:3d:
 +
        98:32:b9:75:66:f4:f0:1b:2d:94:5b:7c:1c:e6:f3:
 +
        04:7f:dd:25:b2:82:a6:41:04:b7:50:93:94:c4:7c:
 +
        34:7e:12:7c:bf:33:54:55:47:8c:42:94:40:8e:34:
 +
        5f:54:04:1d:9e:8c:57:48:d4:b0:f8:e4:03:db:3f:
 +
        68:6c:37:fa:62:14:1c:94:d6:de:f2:2b:68:29:17:
 +
        24:6d:f7:b5:b3:18:79:fd:31:5e:7f:4c:be:c0:99:
 +
        13:cc:e2:97:2b:dc:96:9c:9a:d0:a7:c5:77:82:67:
 +
        c9:cb:a9:e7:68:4a:e1:c5:ba:1c:32:0e:79:40:6e:
 +
        ef:08:d7:a3:b9:5d:1a:df:ce:1a:c7:44:91:4c:d4:
 +
        99:c8:88:69:b3:66:2e:b3:06:f1:f4:22:d7:f2:5f:
 +
        ab:6d
 +
    Exponent: 65537 (0x10001)
 +
 +
Finally, move the key to apk trusted keys storage:
 +
 +
    sudo mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/
 +
 +
To install nginx, run the following command:
 +
 +
    sudo apk add nginx@nginx
 +
 +
The @nginx tag should also be specified when installing packages with dynamic modules:
 +
 +
    sudo apk add nginx-module-image-filter@nginx nginx-module-njs@nginx
 +
 +
 +
</pre>
 +
http://nginx.org/en/linux_packages.html#Alpine
 +
 +
=python=
 +
[https://blog.csdn.net/Kernel_Heart/article/details/107808949  alpine linux 安裝python指定版本以及pip]
  
 
=desktop=
 
=desktop=
第249行: 第402行:
 
=see also=
 
=see also=
  
 
+
[https://blog.csdn.net/diyiday/article/details/91439151  alpine之创建最小docker镜像]
  
 
[https://www.cnblogs.com/jackadam/p/9290366.html Alpine Linux常用命令]
 
[https://www.cnblogs.com/jackadam/p/9290366.html Alpine Linux常用命令]
第277行: 第430行:
 
[http://www.infoq.com/cn/news/2016/01/Alpine-Linux-5M-Docker Alpine Linux,一个只有5M的Docker镜像]
 
[http://www.infoq.com/cn/news/2016/01/Alpine-Linux-5M-Docker Alpine Linux,一个只有5M的Docker镜像]
  
 
+
[https://www.cnblogs.com/xy14/p/11980272.html  Python - 安装 - 在 Alpine Linux 下安装 Python2 ]
  
 
[[category:ops]]
 
[[category:ops]]

2024年11月1日 (五) 16:47的最新版本

NOTE

一般一个软件官方用什么os作容器就用他,不一定是alpine才是最好的 例如 mysql python就可能不是 https://www.armbian.com/

不要轻易使用 Alpine 镜像来构建 Docker 镜像,有坑!

用Alpine会让Python Docker的构建慢50倍

see also

Alpine 修改docker的时区及安装telnet

alpine lnmp 也为docker准备

alpine apk lNMP安装部署

Production LAMP system: Lighttpd + PHP + MySQL

alpine lnmp


How to install PHP 7 fpm on Alpine Linux

pre

占用内存仅仅 37M ,非常的小巧。适合用在树莓派或者其他低内存设备上。 Alpine Linux 折腾记

修改 源 为cst 中国标准时间

#修改源
cat   /etc/apk/repositories


echo 'https://mirrors.ustc.edu.cn/alpine/v3.14/main
https://mirrors.ustc.edu.cn/alpine/v3.14/community'>/etc/apk/repositories



http://mirrors.aliyun.com/alpine/v3.12/main
http://mirrors.aliyun.com/alpine/v3.12/community

echo 'http://mirrors.aliyun.com/alpine/v3.12/main
http://mirrors.aliyun.com/alpine/v3.12/community' >/etc/apk/repositories

apk add --update nodejs npm

#RUN 表明 这是在容器里面的
RUN apk add -U tzdata

#设置时区
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && echo 'Asia/Shanghai' >/etc/timezone

download

x86

https://alpinelinux.org/downloads/

https://mirrors.aliyun.com/alpine/v3.10/releases/x86_64/alpine-standard-3.10.3-x86_64.iso

http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-standard-3.10.1-x86_64.iso

Raspberry Pi

AArch64是ARMv8 架构的一种执行状态 so 下载这个 拿回来试一下 http://mirrors.ustc.edu.cn/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz

http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz

http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/armhf/alpine-rpi-3.8.1-armhf.tar.gz

国内的mirrors 有时比较同步比较慢 https://mirrors.alpinelinux.org/

install on pi

要看

https://wiki.alpinelinux.org/wiki/Raspberry_Pi

Create a Bootable USB

https://my.oschina.net/u/2306127/blog/1587585

https://wiki.alpinelinux.org/wiki/Create_a_Bootable_USB

在树莓派Zero W上安装alpine linux系统

安装过程

输入root 没有密码 直接回车 如果是内网机器 记得打开 root login ssh


13-选择 sys 方式使用磁盘,将系统安装到本地硬盘-格式化硬盘-完成硬盘安装 sys

Alpine linux硬盘安装

configure

国内源 

a. 编辑 /etc/apk/repositories
b. 将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com ; 保存退出即可

非交互 


echo 'http://mirrors.aliyun.com/alpine/v3.14/main
http://mirrors.aliyun.com/alpine/v3.14/community' >/etc/apk/repositories

apk add --update nodejs npm


 cat   /etc/apk/repositories
#/media/cdrom/apks
http://mirrors.aliyun.com/alpine/v3.10/main

http://mirrors.aliyun.com/alpine/v3.10/community
#http://mirror.xtom.com.hk/alpine/v3.10/main
#http://mirror.xtom.com.hk/alpine/v3.10/community
#http://mirror.xtom.com.hk/alpine/edge/main
#http://mirror.xtom.com.hk/alpine/edge/community
#http://mirror.xtom.com.hk/alpine/edge/testing

apk update


alpine:~# cat /etc/apk/repositories 
#/media/cdrom/apks
http://mirrors.ustc.edu.cn/alpine/v3.8/main
http://mirrors.ustc.edu.cn/alpine/v3.8/community
cp /etc/apk/repositories /etc/apk/repositories.bak

软件包管理工具apk的基本使用

可以方便地安装、删除、更新软件。

#查询openssh相关的软件包

apk search  openssh   

#安装一个软件包

apk add  xxx   

#删除已安装的xxx软件包

apk del  xxx   

#获取更多apk包管理的命令参数

apk --help   

 

#比如安装常用的网络相关工具:

#更新软件包索引文件

apk update    

#用于文本方式查看网页,用于测试http协议

apk add curl  

#提供了查看网络连接的协议端口的命令ss,可以替代netstat命令

apk add iproute2  

#drill 命令可以替代dig和nslookup DNS查询命令

apk add drill   

alpine:~# df -h 
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                 10.0M         0     10.0M   0% /dev
shm                     245.0M         0    245.0M   0% /dev/shm
/dev/sda3                29.4G    576.7M     27.3G   2% /
tmpfs                    49.0M    108.0K     48.9M   0% /run
/dev/sda1                92.8M     19.1M     66.8M  22% /boot

Alpine Linux 包管理


5.apk info
$ apk info #列出所有已安装的软件包
$ apk info -a zlib #显示完整的软件包信息
$ apk info --who-owns /sbin/lbu #显示指定文件属于的包


on vps

my.vultr.com ISO Library has apline 3.8 也可以自己上传

Bootstrapping Alpine Linux - Alpine Linux

custom-iso-alpinelinux

Install Alpine Linux on your Linode

docker

 cat   /etc/apk/repositories

http://mirrors.aliyun.com/alpine/v3.10/main
http://mirrors.aliyun.com/alpine/v3.10/community

echo 'http://mirrors.aliyun.com/alpine/v3.18/main
http://mirrors.aliyun.com/alpine/v3.18/community' >/etc/apk/repositories
 apk add openjdk8
apk add  maven




apk add docker

rc-update add docker boot

service docker start

apk add py-pip
apk add python-dev libffi-dev openssl-dev gcc libc-dev make


mkdir -p ~/.pip

#vim  ~/.pip/pip.conf
 cat >>~/.pip/pip.conf<<EOF
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
 
[install]
trusted-host=mirrors.aliyun.com
EOF

pip install more-itertools==5.0.0 #3.10.3

pip install docker-compose


#err  

100% |████████████████████████████████| 81kB 1.2MB/s 
more-itertools requires Python '>=3.5' but the running Python is 2.7.16

nodejs yarn etc

#换源 然后
apk add  --no-cache  nodejs yarn python

https://wiki.alpinelinux.org/wiki/Docker

alpine docker php

github 有个php-worker 搞了一关的 可以参考

Alpine安装php各种扩展

Dockerfile 学习:Docker Alpine PHP 安装扩展

docker官方alpine/php镜像下安装php扩展

Alpine Linux 初上手与安装 PHP7 / MySQL 环境

trouble shooting

alpine镜像crontab无法运行问题

alpine镜像 普通用户 crontab无法运行问题

crond 服务用 root用户启动   or on ci  docker-compose exec -u  root  -T php-worker  sh -c "crond"

如果用官方提供alpine镜像是不自动启动crond的,得手动起
每个用户有单独的文件在/etc/crontabs文件夹
可以用supervisor启动crond,但要用root用户去启动crond,运行其他用户的定时任务

cron itself should run as root, regardless of which user you want to use to run the jobs.

This will install a crontab for user robuser. When cron executes jobs from this particular crontab, it will automatically switch users to robuser. However, cron can’t switch users like that if it’s not running as root, which is why you need to be running cron as root.

 crontab  -l 
crontab: must be suid to work properly

apk add --update busybox-suid

alpine linux中如何使用crontab执行定时任务

Failed to edit crontab (linux Alpine)

Alpine容器启动Crontab任务


Running cron jobs in a Docker Alpine container

ops

Alpine 修改docker的时区及安装telnet

apk  add rsync

install golnag


#1.16 的,新的可能要下载的安装方式 
apk add --no-cache git make musl-dev go

https://stackoverflow.com/questions/52056387/how-to-install-go-in-alpine-linux

install nginx

nstall the prerequisites:

    sudo apk add openssl curl ca-certificates

To set up the apk repository for stable nginx packages, run the following command:

    printf "%s%s%s%s\n" \
        "@nginx " \
        "http://nginx.org/packages/alpine/v" \
        `egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release` \
        "/main" \
        | sudo tee -a /etc/apk/repositories

 Next, import an official nginx signing key so apk could verify the packages authenticity. Fetch the key:

    curl -o /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub

Verify that downloaded file contains the proper key:

    openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout

The output should contain the following modulus:

    Public-Key: (2048 bit)
    Modulus:
        00:fe:14:f6:0a:1a:b8:86:19:fe:cd:ab:02:9f:58:
        2f:37:70:15:74:d6:06:9b:81:55:90:99:96:cc:70:
        5c:de:5b:e8:4c:b2:0c:47:5b:a8:a2:98:3d:11:b1:
        f6:7d:a0:46:df:24:23:c6:d0:24:52:67:ba:69:ab:
        9a:4a:6a:66:2c:db:e1:09:f1:0d:b2:b0:e1:47:1f:
        0a:46:ac:0d:82:f3:3c:8d:02:ce:08:43:19:d9:64:
        86:c4:4e:07:12:c0:5b:43:ba:7d:17:8a:a3:f0:3d:
        98:32:b9:75:66:f4:f0:1b:2d:94:5b:7c:1c:e6:f3:
        04:7f:dd:25:b2:82:a6:41:04:b7:50:93:94:c4:7c:
        34:7e:12:7c:bf:33:54:55:47:8c:42:94:40:8e:34:
        5f:54:04:1d:9e:8c:57:48:d4:b0:f8:e4:03:db:3f:
        68:6c:37:fa:62:14:1c:94:d6:de:f2:2b:68:29:17:
        24:6d:f7:b5:b3:18:79:fd:31:5e:7f:4c:be:c0:99:
        13:cc:e2:97:2b:dc:96:9c:9a:d0:a7:c5:77:82:67:
        c9:cb:a9:e7:68:4a:e1:c5:ba:1c:32:0e:79:40:6e:
        ef:08:d7:a3:b9:5d:1a:df:ce:1a:c7:44:91:4c:d4:
        99:c8:88:69:b3:66:2e:b3:06:f1:f4:22:d7:f2:5f:
        ab:6d
    Exponent: 65537 (0x10001)

Finally, move the key to apk trusted keys storage:

    sudo mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/

To install nginx, run the following command:

    sudo apk add nginx@nginx

The @nginx tag should also be specified when installing packages with dynamic modules:

    sudo apk add nginx-module-image-filter@nginx nginx-module-njs@nginx


http://nginx.org/en/linux_packages.html#Alpine

python

alpine linux 安裝python指定版本以及pip

desktop

暂时没有中文输入法

Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment

Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment

MATE 桌面

Awesome桌面

折腾记


alpine-中文截图乱码问题

问题

Alpine Linux使用了musl,可能和其他Linux发行版使用的glibc实现会有所不同。在容器化中最可能遇到的是DNS问题,即musl实现的DNS服务不会使用resolv.conf文件中的search和domain两个配置,这对于一些通过DNS来进行服务发现的框架可能会遇到问题

docker alpine版本服务中显示中文

see also

alpine之创建最小docker镜像

Alpine Linux常用命令

Alpine linux硬盘安装

Alpine Linux 使用

Alpine Linux 源使用帮助

Alpine Linux配置使用技巧

Alpine linux硬盘安装

BusyBox


Raspberry Pi

Raspberry Pi 3 Alpine Linux arm64

Raspberry Pi

other

alpine linux填坑之路安装php-bcmath

docker(13):alpinelinux安装jenkins

Alpine Linux,一个只有5M的Docker镜像

Python - 安装 - 在 Alpine Linux 下安装 Python2