Skip to content

robwdux/docker-alpine-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-alpine-base

See below for help with Alpine Linux

...start your Dockerfile

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

Test Drive, Iterate for a new image

Interactively test commands and such then record in a Dockerfile for a new project

Build or run with docker-compose

# 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"
}

shell in interactively

sudo docker run --rm -it \
                --name base \
                robwdux/alpine-base \
                sh

search for and install packages, build from source

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

Take advantage of repo pinning support added

Target edge branch and the associated repositories

# 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

Handling Build Dependencies

Purge the bloat after they have served the purpose

# 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

example: shell into a daemonized running container

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

Working with Alpine Linux

command reference

  • busybox shell readme

  • command substituion $( ... ), pipefail, substring and replacement parameter expansion

  • redirect stderr to stdout &>

  • not supported: brace expansion file{1..2}, arrays, aliases, or jobcontrol

Differences from glibc

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages