参考:
For Windows 10(failed)
Reference:
Run Linux containers on Windows
Preparation
- hyper-v installed
- docker installed (2.2.0 install cannot be success. recommend 2.1.0)
Install(Method 1)
while, I update docker.exe everything goes well.
- Download
docker.exefrom Docker Master Binaries - Replace
C:\Program Files\Docker\Docker\resources\bin\docker.exeyou download from link above, and you can download any image from container manager: Kitematic
Install(method 2 failed)
-
Install docker desktop and download container manager: Kitematic
-
download: Canonical Partner Images of Ubuntu for Linux containers on Microsoft Hyper-V and unzip it.
-
mkdir C:\\lcowused as scratch space for Docker while preparing the containers. -
mkdir C:\\Program Files\\Linux Containerswhere the Ubuntu container image will live. -
TIPS: never change the path:
C:\\Program Files\\Linux Containers, it must be there. -
Save script below to
.\set_perms.ps1:-
param( [string] $Root ) # Give the virtual machines group full control $acl = Get-Acl -Path $Root $vmGroupRule = new-object System.Security.AccessControl.FileSystemAccessRule("NT VIRTUAL MACHINE\Virtual Machines", "FullControl","ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($vmGroupRule) Set-Acl -AclObject $acl -Path $Root -
You will need to give this folder extra permissions to allow Docker to use the images from it. Run the following Powershell script in an administrator Powershell window:
-
TIP You may need to run
Set-ExecutionPolicy -Scope process unrestrictedto be allowed to run unsigned Powershell scripts. -
.\set_perms.ps1 "C:\\Program Files\\Linux Containers"
-
-
Now, copy the Ubuntu container image
.vhdxfile that was decompressed at the previous step touvm.vhdxunderC:\Program Files\Linux Containers.
For Ubuntu
系统要求
use command blow:
uname -a
or
cat /proc/version
to get the kenrel version that is must biger than 3.10.
Notice: Your Ubuntu version must biger than 12.04.
First to update or have these packages which is blow:
- linux-image-generic-lts-trusty (必备)
- linux-headers-generic-lts-trusty (必备)
- xserver-xorg-lts-trusty (带图形界面时必备)
- libgl1-mesa-glx-lts-trusty(带图形界面时必备)
To use aufs storage,you’d better get the package:linux-image-extra
sudo apt-get install -y linux-image-extra-$(uname -r)
添加镜像源
首先需要安装 apt-transport-https 包支持 https 协议的源。
sudo apt-get install -y apt-transport-https
添加源的 gpg 密钥。
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
获取当前操作系统的代号。
lsb_release -c
// echo info!
Codename: wily
12.04 (LTS) 代号为 precise,14.04 (LTS) 代号为 trusty,15.04 代号为 vivid,15.10 代号为 wily。
接下来就可以添加 Docker 的官方 apt 软件源了。通过下面命令创建 /etc/apt/sources.list.d/docker.list 文件,并写入源的地址内容。非 wily 版本的系统注意修改为自己对应的代号。
sudo cat <<EOF > /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-wily main
EOF
如果执行报权限不足,请直接 su 用 root 用户执行。
添加成功后,更新 apt 软件包缓存。
sudo apt-get update