MENU

wsl中基于alpine构建docker镜像

March 31, 2022 • linux相关

基于极致精简的 Alpine linux 发行版来构建 truffle
1。查看对应依赖库的版本号:

https://pkgs.alpinelinux.org/packages

2。先写好配置文件:

FROM alpine:3.15.3
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories && \
    apk add --no-cache curl=7.80.0-r0 && \
    apk add --no-cache gcc=10.3.1_git20211027-r0 && \
    apk add --no-cache g++=10.3.1_git20211027-r0 && \
    apk add --no-cache make=4.3-r0 && \
    apk add --no-cache nodejs=16.14.2-r0 && \
    apk add --no-cache npm=8.1.3-r0  && \
    apk add --no-cache vim=8.2.4173-r0 && \
    apk add --no-cache python3=3.9.7-r4 && \
    npm install -g truffle

3。基于 Dockerfile 构建:

docker build -t alpine-node-truffle .

4。启动容器:

docker run -itd --restart=always --name truffle alpine-node-truffle:latest

5。进入docker命令行:

docker exec -it truffle /bin/sh

资料

 https://nosaid.com/article/nodejs-image-with-alpine
 https://www.quchao.net/Alpine.html