Introduction to Alpine Linux usage
Directory:
A brief introduction of Alpine
Second, alpine Local installation
Third, alpine under the Docker operation
Iv. configuration and use of Alpine
4.1 Network related files
4.2 Update the domestic source
4.3 Basic use of package management tools APK
4.4 Open SSH Service
4.5 Installation Nginx
A brief introduction of Alpine
Alpine means "high mountains," such as Alpine plants Alpine plants, Alpine skiing alpine skiing, the Alpine Resort Alpine resorts.
Alpine Linux Site Home page annotated "Small." Simple. Secure. Alpine Linux is a security-oriented, lightweight Linux distribution based on MUSL libc and BusyBox. " The following features are summarized:
1, Compact: Based on MUSL libc and BusyBox, and busybox as small, the smallest Docker mirrors only 5MB;
2, Security: For the safety of the lightweight release version;
3, simple: The provision of APK package management tools, software search, installation, deletion, upgrade are very convenient.
4, suitable for the use of containers: because of compact, full-featured, very suitable as a container for the basic image.
Second, alpine Local installation
Alpine Linux is a complete operating system that, like other operating systems, can install Alpine on a local hard drive. We can create a VirtualBox virtual machine that installs the system under VirtualBox for test use. The specific installation process, see I wrote another article "Alpine Linux hard Disk Installation", Address: http://blog.csdn.net/csdn_duomaomao/article/details/76053229.
Mainly during the installation process, specify some basic computer settings, such as keyboard layout, host name, network card, IP address, root password modification, time zone settings, software warehouse address, SSH server, NTP client, system installation mode, disk format, etc.
Third, alpine under the Docker operation
1, Docker under the operation
Official Alpine Mirrored document: http://gliderlabs.viewdocs.io/docker-alpine/
You can use Docker Toolbox to create a Docker virtual host that runs Alpine Docker containers in the Docker environment of that host. The container is a Alpine Linux system,
Docker Pull Alpine
Docker run-it--name Myalpine Alpine
2, as the Docker container of the base image
Based on alpine mirroring, create a MySQL container with a mirrored size of only 36.5MB
The same way to use the Ubuntu system as the base image, the mirror size of 184MB,
Contents of Dockerfile File:
From alpine:3.6
RUN apk Add--no-cache mysql-client
entrypoint ["MySQL"]
Create a test/mysqlclient:1.0 mirror
Docker build-t test/mysqlclient:1.0.
Iv. configuration and use of Alpine
4.1 Network related files
#主机名文件
/etc/hostname
#使用新设置的主机名立刻生效, execute the following command:
Hostname-f/etc/hostname
#主机IP和域名映射文件
/etc/hosts
#文件内容为:
192.168.99.100 alpine.csdn.net
#DNS Server configuration file
/etc/resolv.conf
#文件内容为:
NameServer 218.2.135.1
NameServer 202.102.24.35
#网卡配置文件
/etc/network/interfaces
#文件内容为:
Auto Lo
Iface Lo inet Loopback
Auto Eth0
Iface eth0 inet Static
Address 192.168.3.166
Netmask 255.255.255.0
Gateway 192.168.3.254
#修改完相关配置以后, restart the network service:
/etc/init.d/networking restart
Network-related documents, see more: https://wiki.alpinelinux.org/wiki/Configure_Networking
4.2 Update the domestic source
# The source file for Alpine is:
/etc/apk/repositories,
# The default source address is: http://dl-cdn.alpinelinux.org/
#可以编辑源文件/etc/apk/repositories,
#采用国内阿里云的源, the contents of the file are:
https://mirrors.aliyun.com/alpine/v3.6/main/
https://mirrors.aliyun.com/alpine/v3.6/community/
# If you use the source of the Chinese University of Science and Technology, the document reads:
https://mirrors.ustc.edu.cn/alpine/v3.6/main/
https://mirrors.ustc.edu.cn/alpine/v3.6/community/
4.3 Basic use of package management tools APK
Alpine provides a very useful APK package management tool,
Can easily install, delete, update software.
#查询openssh相关的软件包
APK Search OpenSSH
#安装一个软件包
APK Add xxx
#删除已安装的xxx软件包
APK del xxx
#获取更多apk包管理的命令参数
APK--help
#比如安装常用的网络相关工具:
#更新软件包索引文件
APK update
#用于文本方式查看网页, for testing the HTTP protocol
APK Add Curl
#提供了查看网络连接的协议端口的命令ss, you can override the Netstat command
APK Add Iproute2
#drill commands can override dig and nslookup DNS query commands
APK Add Drill
#测试192.168.3.166 's 80 port to see if the Web service is properly accessible.
Curl 192.168.3.166
#查看建立的TCP <