当前位置: 首页 > 工具软件 > docker-alpine > 使用案例 >

docker创建Alpine镜像

衡翰翮
2023-12-01

1. 什么是Alpine

Alpine Linux 是一个社区开发的面向安全应用的轻量级Linux发行版,适合用来做Docker镜像、路由器、防火墙、VPNs、VoIP 盒子 以及服务器的操作系统,基于musl libc和Busybox,镜像大小只有5M,并且还提供了包管理工具apk查询和安装软件包。

2. 获取Alpine镜像

docker search Alpine
$  docker search alpine
NAME                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
alpine                                 A minimal Docker image based on Alpine Linux…   5587                [OK]                
mhart/alpine-node                      Minimal Node.js built on Alpine Linux           439                                     
anapsix/alpine-java                    Oracle Java 8 (and 7) with GLIBC 2.28 over A…   421                                     [OK]
frolvlad/alpine-glibc                  Alpine Docker image with glibc (~12MB)          210                                     [OK]
gliderlabs/alpine                      Image based on Alpine Linux will help you wi…   180                                     
mvertes/alpine-mongo                   light MongoDB container                         105                                     [OK]
alpine/git                             A  simple git container running in alpine li…   97                                      [OK]
yobasystems/alpine-mariadb             MariaDB running on Alpine Linux [docker] [am…   46                                      [OK]
kiasaki/alpine-postgres                PostgreSQL docker image based on Alpine Linux   44                                      [OK]
alpine/socat                           Run socat command in alpine container           36                                      [OK]
davidcaste/alpine-tomcat               Apache Tomcat 7/8 using Oracle Java 7/8 with…   36                                      [OK]
zzrot/alpine-caddy                     Caddy Server Docker Container running on Alp…   35                                      [OK]
easypi/alpine-arm                      AlpineLinux for RaspberryPi                     32                                      
jfloff/alpine-python                   A small, more complete, Python Docker image …   26                                      [OK]
byrnedo/alpine-curl                    Alpine linux with curl installed and set as …   26                                      [OK]
hermsi/alpine-sshd                     Dockerize your OpenSSH-server with rsync and…   23                                      [OK]
etopian/alpine-php-wordpress           Alpine WordPress Nginx PHP-FPM WP-CLI           21                                      [OK]
hermsi/alpine-fpm-php                  Dockerize your FPM PHP 7.4 upon a lightweigh…   18                                      [OK]
bashell/alpine-bash                    Alpine Linux with /bin/bash as a default she…   13                                      [OK]
zenika/alpine-chrome                   Chrome running in headless mode in a tiny Al…   13                                      [OK]
davidcaste/alpine-java-unlimited-jce   Oracle Java 8 (and 7) with GLIBC 2.21 over A…   13                                      [OK]
spotify/alpine                         Alpine image with `bash` and `curl`.            9                                       [OK]
tenstartups/alpine                     Alpine linux base docker image with useful p…   8                                       [OK]
rawmind/alpine-traefik                 This image is the traefik base. It comes fro…   5                                       [OK]
hermsi/alpine-varnish                  Dockerize Varnish upon a lightweight alpine-…   1                                       [OK]

3. 获取Alpine镜像

1) docker pull 方法

docker pull alpine:latest
docker pull alpine:latest 
latest: Pulling from library/alpine
9d48c3bd43c5: Pull complete 
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest

2) dockerfile 文件

mkdir alpine && cd alpine

touch Dockerfile
'''
#escape=
#This docker file uses alpine:latest image
#VERSION 1.0
#Author: Swift
#e-mail: ilyzhaoxin@sina.com
#DateTime: 2019-08-27 21:15
from alpine:latest
RUN apk add --no-cache mysql-client
ENTRYPOINT ['mysql']
'''

docker build .

查看获取到到镜像如下所示:

 

 类似资料: