See below for help with Alpine Linux
FROM robwdux/alpine-base
-
Included are ca-certificates and full featured sed (runtime config replacements), refrain from installing bash... no Alpine packages rely on it and existing shell scripts should work using #!/bin/sh or require minimal modification beyond that
-
Repo pinning supported for Edge branch
-
Package mirrors deliverd by Fastly CDN courtesy of Gliderlabs
Interactively test commands and such then record in a Dockerfile for a new project
# add short alias for docker-compose
echo "alias dc='docker-compose '" >> ~/.bashrc && source ~/.bashrc
# the repo
git clone https://github.com/robwdux/docker-alpine-base.git
cd docker-alpine-base/
# build and run (image doesn't exist locally)
dc run --rm -ti base sh
# build explicitly
dc build
# build with meta data via build args for git info
sudo ./build.sh
# view meta data
$ docker inspect --format '{{ json .Config.Labels }}' robwdux/alpine-base:3.4 | jq
{
"GIT_COMMIT": "e8511e87d67a72128b2631ee5ef45bf7f64dc82a",
"GIT_COMMIT_AUTHOR": "rob dux [email protected]",
"GIT_COMMIT_DATE": "2016-07-04T20:08:24-05:00",
"GIT_REPO_URL": "https://github.com/robwdux/docker-alpine-base.git"
}
sudo docker run --rm -it \
--name base \
robwdux/alpine-base \
sh
Reference APKBUILDs for source builds if official ones do not already exist in Docker Library
for example: offical alpine ruby image
$ apk update && apk search rabbit*
rabbitmq-c-dev-0.8.0-r0
py-rabbit-1.1.0-r0
rabbitmq-c-doc-0.8.0-r0
rabbitmq-c-0.8.0-r0
rabbitmq-c-utils-0.8.0-r0
$ apk info rabbitmq-c
rabbitmq-c-0.8.0-r0 description:
RabbitMQ C client
rabbitmq-c-0.8.0-r0 webpage:
https://github.com/alanxz/rabbitmq-c
rabbitmq-c-0.8.0-r0 installed size:
126976
# keep it tidy, no apk cache left behind.
# install any package from current release, any repo (main,community, testing)
# or from particular edge repos
apk add --no-cache \
# edge branch, main repository
redis@edge \
# edge branch, community repository
bmon@community \
# edge branch, testing repository
rabbitmq-c@testing
# tag a group of apks installed, simplifies removal at a later time, e.g. build dependencies
apk add --no-cache --virtual .buildDeps \
make \
autoconf \
gcc \
linux-headers \
libc-dev ...
# make && make install
# remove
apk del .buildDeps && rm -rf /usr/src
sudo docker run -d \
--name base \
robwdux/alpine-base \
ping 8.8.8.8 && \
sudo docker exec -it base bash
security, simplicity and resource efficiency
-
command substituion $( ... ), pipefail, substring and replacement parameter expansion
-
redirect stderr to stdout &>
-
not supported: brace expansion file{1..2}, arrays, aliases, or jobcontrol