乐虎游戏|乐虎国际登录|欢迎你

bbin官网下载CentOS服务器上安装 Docker详细教程,centosdocker

日期:2019-12-16编辑作者:计算机资讯

CentOS服务器上安装 Docker详细教程,centosdocker

1.

[[email protected] osem-master]#  sudo yum install -y yum-utils 
>   device-mapper-persistent-data 
>   lvm2
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: mirror.lzu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com

2.

[[email protected] osem-master]# sudo yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror, refresh-packagekit
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
docker-ce.repo                                                                   | 2.4 kB     00:00     
repo saved to /etc/yum.repos.d/docker-ce.repo

3.

[[email protected] osem-master]# sudo yum-config-manager --enable docker-ce-edge
已加载插件:fastestmirror, refresh-packagekit
========================================= repo: docker-ce-edge =========================================
[docker-ce-edge]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6
baseurl = https://download.docker.com/linux/centos/7/x86_64/edge
cache = 0
cachedir = /var/cache/yum/x86_64/6/docker-ce-edge
cost = 1000
enabled = 1
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/6/docker-ce-edge/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/6/docker-ce-edge/gpgdir
gpgkey = https://download.docker.com/linux/centos/gpg
hdrdir = /var/cache/yum/x86_64/6/docker-ce-edge/headers
http_caching = all
includepkgs = 
keepalive = True
mdpolicy = group:primary
mediaid = 
metadata_expire = 21600
metalink = 
mirrorlist = 
mirrorlist_expire = 86400
name = Docker CE Edge - x86_64
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/6/docker-ce-edge
pkgdir = /var/cache/yum/x86_64/6/docker-ce-edge/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
username = 

4.

Go to https://download.docker.com/linux/centos/7/x86_64/stable/Packages/ and download the .rpm file for the Docker version you want to install.

5.

bbin官网下载 1

stop?

目前,CentOS 仅发行版本中的内核支持 Docker。

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

Docker 运行在?CentOS-6.5?或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本

 

查看内核版本:

uname -r

[[email protected] osem-master]$ uname -r
3.10.0-693.el7.x86_64

安装:

# yum -y install docker

启动服务:

# service docker start

检测安装:

# docker run hello-world

Docker详细教程,centosdocker 1. [[email protected] osem-master]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2Loaded plugins: fast...

1. 查看CentOS版本

由于安装Docker时,Docker支持

  • CentOS 7 (64-bit)
  • CentOS 6.5 (64-bit) 或更高的版本

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本

CentOS 7 的内核一般都是3.10的,而CentOS 6.X 的内核一般都是2.6,在2.6的内核下,Docker运行会比较卡,所以一般会选择升级到3.10版本。

CentOS6.X 升级内核 至 3.10

CentOS 6.9安装Docker

由于Docker要求运行的linux内核版本为3.8以上,因此,在安装之前,要查看一下宿主机操作系统的内核版本,否则如果是内核低于3.8,能够成功安装Docker,但进入Docker后,会自动退出。

1、下载安装CentOS 6.9

CentOS 6 系列,最新版本为6.9,由于 Docker 只能运行在64位系统上,因此到CentOS的官网上选择某个镜像 下载  CentOS 6.9 64位

2、升级CentOS的Linux内核

CentOS 6.9默认的linux内核版本为2.6,CentOS 7默认的linux内核版本为3.10,因此,对于CentOS 6.9则需进行内核版本的升级

1)进入更新linux内核的网址 

2)按照操作指引进行内核更新,在root账号下执行以下指令

(1)导入 public key

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

(2)安装ELRepo

针对Centos6,

rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

针对Cenos7,

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm (external link)

(3)安装kernel

长期支持的版本,稳定(推荐)

yum --enablerepo=elrepo-kernel install -y kernel-lt

主线版本(mainline)

yum --enablerepo=elrepo-kernel install -y kernel-ml

(4)修改Grub引导顺序,设置默认启动新升级的内核

编辑grub.conf文件

vi /etc/grub.conf

将 default 修改为新安装内核的位置

# grub.conf generated by anaconda
#
default=0    #一般最新安装的内核在第一个位置,将其修改为 0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.28-1.el6.elrepo.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-3.10.28-1.el6.elrepo.x86_64 ro root=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-3.10.28-1.el6.elrepo.x86_64.img
title CentOS (2.6.32-431.3.1.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-431.3.1.el6.x86_64 ro root=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-431.3.1.el6.x86_64.img

(5)重启,内核升级完成

reboot

3、安装 docker

(1)禁用 selinux

因为selinux和LXC有冲突,所以禁用掉selinux

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

(2)配置Fedora EPEL 源

由于CentOS 6.x与7.x安装docker是有一些不同的,CentOS 6.x上docker的安装包叫docker-io,来源于Fedora epel库,这个仓库维护了大量的没有包含在发行版中的软件,所以先要安装EPEL,而CentOS 7.x的docker直接包含在官方镜像源的Extras仓库(CentOS-Base.repo下的[extras]节enable=1启用)

yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

(3)安装docker

安装 docker-io

yum install -y docker-io

(4)启动docker

service docker start

(5)查看docker版本

docker version

Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
OS/Arch (server): linux/amd64

(6)执行docker hello-world

拉取 hello-world 镜像

docker pull hello-world

执行 hello-world

docker run hello-world

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (Assuming it was not already locally available.)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

For more examples and ideas, visit:
 http://docs.docker.com/userguide/

出现上面的输出信息表示 Docker 已经完全安装成功了

4、卸载docker

如果要卸载docker,也非常简单,查看docker安装包

yum list installed | grep docker

然后删除安装包

yum -y remove docker-io.x86_64

删除镜像或容器

rm -rf /var/lib/docker

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

Docker安装应用(CentOS 6.5_x64)  

Ubuntu 16.04 服务器上配置使用 Docker   

Ubuntu 15.04下安装Docker   

Docker 安装实例  

Docker 创建基础镜像   

在 Ubuntu 15.04 上如何安装Docker及基本用法  

Ubuntu 16.04上Docker使用手记  

使用Docker分分钟启动常用应用   

Ubuntu 16.04下Docker修改配置文件不生效解决办法   

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

6.9安装Docker 由于Docker要求运行的linux内核版本为3.8以上,因此,在安装之前,要查看一下宿主机操作系统的内核版本,否则如果是内核...

2. 安装docker-io

[root@localhost ~]# yum install docker-io

如何显示没有该package,则先执行下面这条指令,安装yum源:

[root@localhost ~]# yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

3. Docker操作

查看Docker版本信息

[root@localhost ~]# docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Get http:///var/run/docker.sock/v1.19/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

本文由乐虎游戏发布于计算机资讯,转载请注明出处:bbin官网下载CentOS服务器上安装 Docker详细教程,centosdocker

关键词:

Linux 中改过拼写错误的Bash 命令方法,linuxbash

Linux 中纠正拼写错误的Bash 命令方法,linuxbash 我知道你可以按下向上箭头来调出你运行过的命令,然后使用左/右键移...

详细>>

第五章 linux重定向和管道

linux关于重定向的知识讲解,linux重定向讲解 1.输出重定向的两种方式: 覆盖原文件内容 追加写,不覆盖原文件内容 2...

详细>>

Linux(CentOS 6.5) 下Nginx 安装

Linux(CentOS 6.5) 下Nginx 安装 Nginx一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,一个Apache服务器不错...

详细>>

乐虎国际登录:Win2008 R2 mysql 5.5 zip格式mysql 安装与配置

Win2008 R2 mysql 5.5 zip格式mysql 安装与配置 Win2008 R2 zip格式mysql 安装与配置 一、百度mysql5.6 ZIP 64位免安装版 下载好后 解...

详细>>