docker安装部署

1. 如何安装 Epel源到 RHEL/CentOS 7/6/5?
  

RHEL/CentOS 7
rpm -ivh http://mirrors.ustc.edu.cn/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm


RHEL/CentOS 6 
## RHEL/CentOS 6 
# wget 
http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# rpm -ivh epel-release-6.noarch.rpm
如何检查epel是否安装成功?
使用一下命令:
# yum repolist 
[root@17-150 ~]# yum repolist 
已加载插件:fastestmirror
base | 3.6 kB 00:00:00 
epel/x86_64/metalink | 5.6 kB 00:00:00 
epel | 4.3 kB 00:00:00 
extras | 3.4 kB 00:00:00 
updates | 3.4 kB 00:00:00 
(1/5): extras/7/x86_64/primary_db | 191 kB 00:00:00 
(2/5): epel/x86_64/group_gz | 170 kB 00:00:00 
(3/5): epel/x86_64/updateinfo | 807 kB 00:00:01 
(4/5): updates/7/x86_64/primary_db | 7.8 MB 00:00:04 
(5/5): epel/x86_64/primary_db | 4.7 MB 00:01:05 
Determining fastest mirrors
* base: centos.ustc.edu.cn
* epel: mirrors.ustc.edu.cn
* extras: mirrors.sohu.com
* updates: mirrors.sohu.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base 9,363
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 11,769
extras/7/x86_64 CentOS-7 - Extras 449
updates/7/x86_64 CentOS-7 - Updates 2,146
repolist: 23,727

2. 安装docker-io

yum -y install docker-io 
yum install docker-engine

3. 启动docker服务

/etc/init.d/docker start 
Starting cgconfig service: [ OK ] 
Starting docker: [ OK ] 

chkconfig docker on #设置docker服务开机启动


4. docker命令补全
  安装docker自带包:
  缺少下面的包,TAB会报错

yum install -y bash-completion
sh /usr/share/bash-completion/bash_completion  或者执行 source /usr/share/bash-completion/completions/docker

  显然,该脚本是用于bash自动补全的,但是,不幸的是,直接 source 执行该脚本后,docker命令后敲tab,有如下错误: 

docker -bash: _get_comp_words_by_ref: command not found 
-bash: [: 1: unary operator expected 
-bash: [: 1: unary operator expected 
-bash: [: -eq: unary operator expected 
-bash: _get_comp_words_by_ref: command not found 
-bash: [: 1: unary operator expected 
-bash: [: 1: unary operator expected 
-bash: [: -eq: unary operator expected

  难道docker的bash自动补全还能有问题? 

解决办法如下:
  我这里虽然安装了bash-completion ,但是没有执行其中的一个文件:
  /usr/share/bash-completion/bash_completion 
  该文件中有上面缺少的命令,执行该文件,重新开一个shell终端 就解决了。
5. 如何使用docker加速器
  安装/升级你的Docker客户端
  推荐安装1.10.0以上版本的Docker客户端。
  您可以通过阿里云的镜像仓库下载:docker-engine、docker-ce
  或执行以下命令:

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -

  针对Docker客户端版本大于1.10的用户

  您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://sv1txjq6.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

6. 阿里云镜像站
  http://mirrors.aliyun.com/

posted @ 2018-10-22 17:03  七月流星雨  阅读(316)  评论(0编辑  收藏  举报