Centos7中安装docker

本文详细介绍如何在CentOS 7系统上安装Docker Engine,包括使用yum安装、通过脚本安装、设置开机启动及卸载等内容。同时,还介绍了如何验证安装是否成功以及为普通用户授权的方法。

CentOS

Docker 可以运行在CentOS 7系列,也可以安装在其他二进制兼容 EL7发行版的系统中,比如 科学Linux(Scientific Linux)可以成功安装,但是Docker没有做测试或者支持 Docker 在这些发行版上安装。

这一节会指导你去安装使用 Docker-managed 发布包和安装机制。确保使用的这些包是Docker 最新版的。如果你想要使用 CentOS-managed 包,请查询 CentOS 的文档 

前提

Docker要求64位的系统,对CentOS版本不做要求,并且你的内核必须是3.10及以上。

检查你当前内核的版本,可以在终端中使用 uname -r 去显示你的内核版本: 


 
$ uname -r
3.10.0-229.el7.x86_64

最后,推荐完全更新你的系统,请牢记被打补丁来修复了任何潜在的内核 bugs。任何被上报的内核 bugs 应该已经完全使用最新的内核软件包被修复了。

安装

有两种方法安装 Docker Engine:

第一种:可以使用 yum 管理器安装,或者使用 curl  get.docker.com 

第二种:运行一个通过 yum 包管理的安装脚本安装;

Install with yum

  1. 登陆你的机器使用 sudo or root 特权.

  2. 确保你的yum包是最新的:

       
    $ sudo yum update


  3. 添加yum repo.

       
    $ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
    [dockerrepo]
    name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
    enabled=1
    gpgcheck=1
    gpgkey=https://yum.dockerproject.org/gpg
    EOF

  4. 安装 Docker package.

    $ sudo yum install docker-engine 

  5. 启动Docker daemon.

    $ sudo service docker start 

  6. 通过在容器中运行一个测试镜像确保docker安装成功。

       
    $ sudo docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from hello-world
    a8219747be10: Pull complete
    91c95931e552: Already exists
    hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
    Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
    Status: Downloaded newer image for hello-world:latest
    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 itto 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/

使用脚本安装

  1.  登陆你的机器使用sudo或者root特权

  2. 确保你的yum是最新的

    $ sudo yum update 

  3. 运行Docker安装脚本

    $ curl -sSL https://get.docker.com/ | sh 

    这个脚本添加docker.repo仓库,然后安装Docker

  4. 启动Docker daemon

    $ sudo service docker start 

  5. 通过在容器中运行一个测试镜像确保docker安装成功

    $ sudo docker run hello-world 

创建一个docker组

Docker daemon绑定了一个Unix socket而不是TCP端口。默认root用户拥有Unix socket,其他用户可以通过sudo来访问它。出于这个原因,docker daemon总是以root用户身份运行。

当你用docker命令时,为了避免使用sudo命令,我们可以创建一个叫做 docker 的组 ,并且将用户添加进去。当再次启动docker daemon时,使得Unix socket 读写的所有权以docker组的身份运行。

Warning: 在进行docker操作时,这个docker 组和root用户是等价的;关于如何影响系统安全想要获取更多详细信息,可以参照Docker Daemon Attack Surface

接下来创建docker组并添加用户user:

  1. 登陆系统Centos。

  2. 创建docker组并添加用户

    $sudo usermod -aG docker your_username 

  3.   注销系统然后重新登录系统,确保你的用户正在运行并且有正确的权限

  4. 通过使用不加sudo的docker命令运行一个容器来验证以上几步的正确性:

    $ docker run hello-world 

设置docker daemon开机启动

为了确保Docker在系统启动时运行,可以这样做:

   $ sudo systemctl enable docker 

卸载

你可以使用yum命令卸载Docker

  1. 列出已经安装的软件包。

       
    $ yum list installed | grep docker
    yum list installed | grep docker
    docker-engine.x86_64 1.7.1-1.el7 @/docker-engine-1.7.1-1.el7.x86_64.rpm

  2. 删除软件包.

    $ sudo yum -y remove docker-engine.x86_64 

    这个命令不会删除主机上的镜像、容器、卷、用户创建的配置文件

  3. 删除所有镜像、容器和卷,可以使用如下命令:

    $ rm -rf /var/lib/docker 

  4. 查找删除用户创建的任何docker文件。.

Matlab基于粒子群优化算法及鲁棒MPPT控制器提高光伏并网的效率内容概要:本文围绕Matlab在电力系统优化与控制领域的应用展开,重点介绍了基于粒子群优化算法(PSO)鲁棒MPPT控制器提升光伏并网效率的技术方案。通过Matlab代码实现,结合智能优化算法与先进控制策略,对光伏发电系统的最大功率点跟踪进行优化,有效提高了系统在不同光照条件下的能量转换效率并网稳定性。同时,文档还涵盖了多种电力系统应用场景,如微电网调度、储能配置、鲁棒控制等,展示了Matlab在科研复现与工程仿真中的强大能力。; 适合人群:具备一定电力系统基础知识Matlab编程能力的高校研究生、科研人员及从事新能源系统开发的工程师;尤其适合关注光伏并网技术、智能优化算法应用与MPPT控制策略研究的专业人士。; 使用场景及目标:①利用粒子群算法优化光伏系统MPPT控制器参数,提升动态响应速度与稳态精度;②研究鲁棒控制策略在光伏并网系统中的抗干扰能力;③复现已发表的高水平论文(如EI、SCI)中的仿真案例,支撑科研项目与学术写作。; 阅读建议:建议结合文中提供的Matlab代码与Simulink模型进行实践操作,重点关注算法实现细节与系统参数设置,同时参考链接中的完整资源下载以获取更多复现实例,加深对优化算法与控制系统设计的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值