阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu 14.04.4 Server 下安装部署 Docker

114次阅读
没有评论

共计 4758 个字符,预计需要花费 12 分钟才能阅读完成。

环境:Ubuntu-14.04.4-server-amd64

1、更换阿里云源
备份源配置文件:
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
$ sudo vim /etc/apt/sources.list
删除文件内容,更新为:
deb http://mirrors.aliyun.com/ubuntu trusty main restricted
deb-src http://mirrors.aliyun.com/ubuntu trusty main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu trusty-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu trusty-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu trusty universe
deb-src http://mirrors.aliyun.com/ubuntu trusty universe
deb http://mirrors.aliyun.com/ubuntu trusty-updates universe
deb-src http://mirrors.aliyun.com/ubuntu trusty-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu trusty multiverse
deb-src http://mirrors.aliyun.com/ubuntu trusty multiverse
deb http://mirrors.aliyun.com/ubuntu trusty-updates multiverse
deb-src http://mirrors.aliyun.com/ubuntu trusty-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
执行如下命令刷新:
$ sudo apt-get clean
$ sudo apt-get update

2、检查内核版本:
$ uname -r
4.2.0-27-generic

3、更新包信息确保 APT 工作于 https 模式并且安装好 CA 证书:
$ sudo apt-get update
$apt-get install apt-transport-https ca-certificates

4、增加一个新 GPG 密钥:
$ sudo apt-key adv –keyserver hkp://p80.pool.sks-keyservers.net:80 –recv-keys 58118E89F3A912897C070ADBF76221572C52609D

5、新建 docker.list 文件并加入相关内容:
$ sudo vim /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-trusty main
更新 APT 软件包索引:
$ atp-get update
假如存在旧的 repo 则清除:
$ apt-cache policy docker-engine
验证 APT 是否从正确的库中获取:
$ apt-get purge lxc-docker
此命令下载一个测试图像并运行于一个容器中,它将打印一份欣喜然后自动退出。

6、安装 linux-image-extra kernel package
$ sudo apt-get update
$ sudo apt-get install linux-image-extra-$(uname -r)
检查是否有安装 apparmor
$ whereis apparmor
没有的话
$ apt-get install -y apparmor
$ sudo reboot

7、进入 docker 安装阶段
$ sudo apt-get update
安装 docker
$ sudo apt-get install docker-engine
启动 docker 服务
$ sudo service docker start
验证 docker 安装是否 OK
$ sudo docker run hello-world

8、创建一个 docker 组并加入当前用户
$ sudo usermod -aG docker ubuntu
验证
$ docker run hello-world

9、调整内存和交换分区
当运行 docker 出现如下报错:
WARNING: Your kernel does not support cgroup swap limit. WARNING: Your
kernel does not support swap limit capabilities. Limitation discarded.
需要做如下操作:
$ sudo vim /etc/default/grub
设置 GRUB_CMDLINE_LINUX=”cgroup_enable=memory swapaccount=1″
$ sudo update-grub
$ sudo reboot

10、开启 UFW 转发
检查 UFW 是否安装并启动
$ sudo ufw status
$ sudo vim /etc/default/ufw
设置 DEFAULT_FORWARD_POLICY=”ACCEPT”
重启 UFW 服务并使用新的配置
$ sudo ufw reload
放行 2375 端口
$ sudo ufw allow 2375/tcp

11、配置 DNS 服务器
当用台式机启动容器时报错:
WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers
can’t use it. Using default external servers : [8.8.8.8 8.8.4.4]
$ sudo vim /etc/default/docker
设置 DOCKER_OPTS=”–dns 8.8.8.8 –dns 8.8.4.4″
重启 docker 守护进程
$ sudo restart docker
关闭 dnsmasq
$ sudo vim /etc/NetworkManager/NetworkManager.conf
注释掉 dns=dnsmasq
保存后重启 NetworkManager 和 Docker
$ sudo restart network-manager
$ sudo restart docker

12、Ubuntu14.04.4 版本安装 docker 后会将其服务设为开机自启动。
升级 docker
$ sudo apt-get upgrade docker-engine
卸载 docker 包
$ sudo apt-get purge docker-engine
$ sudo apt-get autoremove –purge docker-engine
删除镜像、容器、卷
$ rm -rf /var/lib/docker
同时你需要手动删除用户生成的配置文件,此略!!!

更多 Docker 相关教程见以下内容

Docker 安装应用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm 

Ubuntu 14.04 安装 Docker  http://www.linuxidc.com/linux/2014-08/105656.htm 

Ubuntu 使用 VNC 运行基于 Docker 的桌面系统  http://www.linuxidc.com/Linux/2015-08/121170.htm 

阿里云 CentOS 6.5 模板上安装 Docker http://www.linuxidc.com/Linux/2014-11/109107.htm 

Ubuntu 15.04 下安装 Docker  http://www.linuxidc.com/Linux/2015-07/120444.htm 

在 Ubuntu Trusty 14.04 (LTS) (64-bit)安装 Docker http://www.linuxidc.com/Linux/2014-10/108184.htm 

在 Ubuntu 15.04 上如何安装 Docker 及基本用法 http://www.linuxidc.com/Linux/2015-09/122885.htm 

Docker 的详细介绍:请点这里
Docker 的下载地址:请点这里 

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129686.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计4758字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中