Container "Alpine Linux"

Introduction

Alpine Linux is a very small Linux distribution based on musl libc and busybox. This container is thought for users, that want to build containers with very small footprint without compiling and building on their own. This solution is in between a full blown Debian container and a container built from scratch.

This document will describe how to install Alpine Linux within a container and will show some of the first steps in it.

Install and configure the container

Download the Alpine Linux container and store it on your PC.

This will start a Alpine Linux in the new container.

Login to the container and configure networking

Alpine Linux will start an SSH server that can be used to login. Open a terminal or a putty and enter the configured IP address of the container:


joe@pc ~ $ ssh root@192.168.1.3

When using putty enter the IP address and click connect. The user name is "root", the password is also "root".

The first thing to do is to change the password of the user "root"! This container will behave like a real PC that nasty people want to enter and install their bot net client on it to use it for their nasty goals:


container1:~# passwd

Configure networking now. The IP address has already been set by the configuration of the M3 device. What still is missing is the default gateway Use the tiny editor "vi" to edit the file:


container1:~# vi /etc/local.d/routes.start

The editor vi has two modes:

In this document the M3 device itself should act as the gateway, which is already configured. In this case there is nothing to do here. Otherwise press "i" to enter "edit mode" and change the IP address to the one of the correct gateway. Leave edit mode to store and exit the editor with the keys <ESC>:x (first <ESC> to return to command mode, then the ":" to introduce a command, finally "x" as the command to store and exit vi).

When the IP address of the gateway has changed, the new default route can be set:


container1:~# /etc/init.d/local restart

To be able to resolve domain names the IP address of the DNS server must be set:


container1:~# vi /etc/resolv.conf

The M3 device will most likely always act as the gateway to the internet. If this has not been configured yet (WAN chains, IP routes, IP netfilters like NAT), it should be done now. Please consult the documentation of the M3 devices. Test if the container can reach its targets you can use the tool "ping" in the container:

container1:~# ping insys-icom.com

Install additional programs

Alpine Linux comes with a packet management tool called "apk". It should be updated:


container1:~# apk update

After that packages from a huge pool can be installed, for instance the web server "lighttpd":


container1:~# apk add lighttpd

Start the service:


container1:~# rc-service lighttpd start

Start the service automatically after the container starts:


container1:~# rc-update add lighttpd default

Create a small web page the web server can deliver:


container1:~# vi /var/www/localhost/htdocs/index.html

Create a little web site like this:

<html>
    <body>Hello world!</body>
</html>"

This site should now be accessible with a web browser: http://192.168.1.3

The website of Alpine Linux offers a lot of additional useful documentation like Tutorials or FAQs