2021-08-04 11:35:55 +02:00
2021-04-14 16:15:17 +02:00
2021-06-15 20:58:21 +02:00
2021-06-15 20:56:10 +02:00
2021-08-04 11:35:55 +02:00
2019-02-28 14:44:44 +01:00
2021-08-04 11:35:55 +02:00

= docker-alpine

:ao: alpinelinux.org
:hubp: _/alpine
:hub: https://hub.docker.com/r/{hubp}/

image:https://img.shields.io/docker/stars/{hubp}.svg[link={hub}]
image:https://img.shields.io/docker/pulls/{hubp}.svg[link={hub}]

The official Docker image for https://{ao}[Alpine Linux].
The image is only 5MB and has access to a package repository that is much more featureful than other BusyBox based images.

== Why
Docker images today are big.
Usually much larger than they need to be.
There are a lot of ways to make them smaller, but the Docker populace still jumps to the `ubuntu` base image for most projects.
The size savings over `ubuntu` and other bases are huge:
[source]
----
REPOSITORY  TAG     IMAGE ID      CREATED      SIZE
alpine      latest  961769676411  4 weeks ago  5.58MB
ubuntu      latest  2ca708c1c9cc  2 days ago   64.2MB
debian      latest  c2c03a296d23  9 days ago   114MB
centos      latest  67fa590cfc1c  4 weeks ago  202MB
----
There are images such as `progrium/busybox` which get us close to a minimal container and package system, but these particular BusyBox builds piggyback on the OpenWRT package index, which is often lacking and not tailored towards generic everyday applications.
Alpine Linux has a much more featureful and up to date https://pkgs.{ao}[Package Index]:
[source]
----
$ docker run progrium/busybox opkg-install nodejs
Unknown package 'nodejs'.
Collected errors:
 * opkg_install_cmd: Cannot install package nodejs.

$ docker run alpine apk add --no-cache nodejs
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/7) Installing ca-certificates (20190108-r0)
(2/7) Installing c-ares (1.15.0-r0)
(3/7) Installing libgcc (8.3.0-r0)
(4/7) Installing http-parser (2.8.1-r0)
(5/7) Installing libstdc++ (8.3.0-r0)
(6/7) Installing libuv (1.23.2-r0)
(7/7) Installing nodejs (10.14.2-r0)
Executing busybox-1.29.3-r10.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 31 MiB in 21 packages
----
This makes Alpine Linux a great image base for utilities, as well as production applications.
https://www.{ao}/about/[Read more about Alpine Linux here] and it will become obvious how its mantra fits in right at home with Docker images.

NOTE: All of the example outputs above were last generated/updated on May 3rd 2019.

== Usage
Stop doing this:
[source, dockerfile]
----
FROM ubuntu-debootstrap:14.04
RUN apt-get update -q \
  && DEBIAN_FRONTEND=noninteractive apt-get install -qy mysql-client \
  && apt-get clean \
  && rm -rf /var/lib/apt
ENTRYPOINT ["mysql"]
----
This took 28 seconds to build and yields a 169 MB image.
Start doing this:
[source, dockerfile]
----
FROM alpine:3.9
RUN apk add --no-cache mysql-client
ENTRYPOINT ["mysql"]
----
Only 4 seconds to build and results in a 41 MB image!
S
Description
No description provided
Readme MIT
463 MiB
0 Stars 1 Watchers 0 Forks
Languages
Lua 56.9%
Shell 41.5%
Dockerfile 1.6%