Introduction
Steps to install Alpine docker container
Alpine docker setup
Pull alpine image
root@ubuntu:/personal# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
Digest: sha256:3dcdb92d7432d56604d4545cbd324b14e647b313626d99b889d0626de158f73a
Status: Image is up to date for alpine:latest
Verify that image is loaded
root@ubuntu:/personal# docker images | grep alpine
alpine latest 4e38e38c8ce0 22 hours ago 4.799 MB
Create an alpine docker instance
root@ubuntu:/personal/# docker run -dt --name alpine_docker alpine:latest /bin/ash
25078442f25706372f4a06455ff721764a32c3f7e97de031ec667b510d38921e
root@ubuntu:/personal# docker ps | grep alpine_docker
25078442f257 alpine:latest "/bin/ash" 10 seconds ago Up 9 seconds alpine_docker
Execute alpine docker instance
root@ubuntu:/personal# docker exec -it alpine_docker /bin/ash
/ # ls
bin dev etc home lib linuxrc media mnt proc root run sbin srv sys tmp usr var
/ #
It is done using apk command
Handling dependency installation for cffi package installation
Error on running apk install cffi:
gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -fPIC -DUSE__THREAD -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o
c/_cffi_backend.c:13:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
Resolution:
apk add --no-cache libffi-dev build-base py2-pip python2-dev && pip install cffi
Useful link: https://github.com/gliderlabs/docker-alpine/issues/297
cURL package installation
# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
v3.7.0-151-gf417903f18 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main/]
OK: 5744 distinct packages available
bash-4.4# apk add curl
(1/3) Installing libssh2 (1.8.0-r2)
(2/3) Installing libcurl (7.59.0-r0)
(3/3) Installing curl (7.59.0-r0)
Executing busybox-1.27.2-r7.trigger
OK: 257 MiB in 57 packages
bash-4.4#
Add openssl package
bash-4.4# apk add openssl
(1/1) Installing openssl (1.0.2o-r0)
Executing busybox-1.27.2-r7.trigger
Executing ca-certificates-20171114-r3.trigger
OK: 257 MiB in 58 packages
Example of Dockerfiles using python based on alpine
google519822_student@k8s-workshop-module-1-lab:/kickstart$ cat Dockerfile
# A docker base image based on alpine linux with python 3.6.0 pre-installed.
# Docker images can be stacked on top of each other.
FROM library/python:3.6.0-alpine
# Install tornado library.
RUN pip install tornado
# Copy the webserver python app.
ADD web-server.py /web-server.py
# Set the default execution command for this image.
Reference
https://www.youtube.com/watch?v=axlAUkKzbx8