alpine linux下安装docker
Installation
Run apk add docker
to install Docker on Alpine Linux.
The Docker package is in the 'Community' repository, so if the apk add fails with unsatisfiable constraints, you need to edit the /etc/apk/repositories file to add (or uncomment) a line like:
http://dl-6.alpinelinux.org/alpine/edge/community
强烈推荐使用中科大alipine linux软件源(http://mirrors.ustc.edu.cn/help/alpine.html#id1)
可以使用如下命令:
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
添加
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
apk update
apk add docker
To start the Docker daemon at boot, run:
rc-update add docker boot
Then to start the Docker daemon manually, run:
service docker start
**Note: **You'll need to disable some kernel security flags in order to build images:
sysctl -w kernel.grsecurity.chroot_deny_chmod=0
sysctl -w kernel.grsecurity.chroot_deny_mknod=0
For more information, have a look at the corresponding Github issue.
然后更新下docker 镜像中心的地址,强烈建议用中科大的https://lug.ustc.edu.cn/wiki/mirrors/help/docker
使用说明
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。
请在该配置文件中加入(没有该文件的话,请先建一个):
{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] }
Docker Daemon configuration file 文档: https://docs.docker.com/engine/reference/commandline/dockerd/#/daemon-configuration-file
Docker for Windows 文档: https://docs.docker.com/docker-for-windows/#/docker-daemon
在 Docker 的启动参数中加入:
--registry-mirror=https://docker.mirrors.ustc.edu.cn
Ubuntu 用户(包括使用 systemd 的 Ubuntu 15.04)可以修改 /etc/default/docker 文件,加入如下参数:
DOCKER_OPTS="--registry-mirror=https://docker.mirrors.ustc.edu.cn"
其他 systemd 用户可以通过执行 sudo systemctl edit docker.service 来修改设置, 覆盖默认的启动参数:
[Service] ExecStart= ExecStart=/usr/bin/docker -d -H fd:// --registry-mirror=https://docker.mirrors.ustc.edu.cn