Ubuntu Docker 安装

Docker是PaaS供应商dotCloud开源的一个基于LXC 的高级容器引擎,源代码托管在 GitHub 上, 基于Go语言开发并遵从Apache 2.0协议开源。Docker提供了一种在安全、可重复的环境中自动部署软件的方式,它的出现拉开了基于云计算平台发布产品方式的变革序幕。

Ubuntu Trusty 14.04 (LTS) (64-bit)

https://docs.docker.com/installation/ubuntulinux/

apt-get update
apt-get install docker.io
ln -sf /usr/bin/docker.io /usr/local/bin/docker
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

将Docker仓储key加入apt 源列表

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

添加Docker 到 apt源列表中

sh -c "echo deb https://get.docker.io/ubuntu docker main
> /etc/apt/sources.list.d/docker.list"

更新最新的Docker

apt-get update
apt-get install lxc-docker

 启动、重启、停止

service docker start
service docker restart
service docker stop

如果你想在新的 Docker 容器下创建一个新的 Ubuntu 操作系统,你首先需要 pull 一个 Ubuntu 的 Docker 镜像。下面的命令可以通过网络下载 Docker 镜像:

docker pull ubuntu

你可以使用下面的命令启动 Docker 里面的 Ubuntu 系统。最后的参数“/bin/bash”表示一旦容器启动,首先会执行简单的 bash

docker run -i -t ubuntu /bin/bash

 代理配置

vim /etc/default/docker
export HTTP_PROXY="http://<proxy_host>:<proxy_port>"
export HTTPS_PROXY="http://<proxy_host>:<proxy_port>"
#export http_proxy="http://10.48.127.169:8080"
#export https_proxy="http://10.48.127.169:8080"
#export no_proxy="10.58.9.84"

手动安装Docker

# To install, run the following command as root:
curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.4.1 && chmod +x docker-1.4.1 && sudo mv docker-1.4.1 /usr/local/bin/docker
# Then start docker in daemon mode:
sudo /usr/local/bin/docker -d

Docker run container error

Note: If you get a Cannot start container error mentioning SELinux or permission denied, you may need to update the SELinux policies. This can be done using 

sudo yum upgrade selinux-policy

and then rebooting.
selinux 原因。
1.selinux模式为permissive模式 setenforce 0
2.容器启动,添加--privileged=true
3.关闭selinux
vim /etc/sysconfig/selinux
SELINUX=disabled