zoukankan      html  css  js  c++  java
  • centos7.x docker安装及配置,持续更新

    1. 安装docker-ce [root],ce为docker社区版,免费,ee版为企业版,收费

    列出所有已安装docker

    1 # rpm -qa | grep docker

    删除已安装docker

    1 # rpm -e rpmname

    安装docker-ce

    1 # yum install docker-ce.x86_64 # 此命令会自动安装相关依赖包

    配置Daocloud加速

    1 # curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://8ad7943c.m.daocloud.io

    2. 开启dock服务,并设置开机自启 [root]

    1 # systemctl start docker
    2 # systemctl enable docker.service

    3. 测试docker [root]

    1 # 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.
        (amd64)
     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
    
    Share images, automate workflows, and more with a free Docker ID:
     https://cloud.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/engine/userguide/
    1 # docker info #此命令可以查看dock内image和container信息

    4. 使特定普通用户可以执行dock命令 [root]

    1 # visudo

    在最下方加入此行,此行会允许特定用户以sudo方式运行docker,第一次运行时要求输入该特定用户的密码,以后每隔5分钟重复运行docker命令时需要输入密码:

    1 #docker
    2 username        ALL=(ALL)        /usr/bin/docker

    下面这行的区别在于,不需要输入sudo密码,但是并不安全

    1 #docker
    2 username        ALL=(ALL)      NOPASSWD: /usr/bin/docker

    设置/usr/bin/docker别名

    1 # alias docker="sudo /usr/bin/docker" 

    直接在命令行输入上述命令时,此命令不会永久生效,如果想永久生效,将其加入对应用户的.bashrc中即可

    1 vim ~/.bashrc
     1 # .bashrc
     2 
     3 # User specific aliases and functions
     4 
     5 alias rm='rm -i'
     6 alias cp='cp -i'
     7 alias mv='mv -i'
     8 alias docker="sudo /usr/bin/docker"
     9 
    10 # Source global definitions
    11 if [ -f /etc/bashrc ]; then
    12         . /etc/bashrc
    13 fi
    14 ...

    5. 测试 [username]

    配置完上述命令之后,指定的普通用户就可以直接运行docker命令了

    1 # dock info

     

     参考自:

    http://cloud.51cto.com/art/201508/488478.htm

    http://www.jianshu.com/p/e9b6f5a6f198

    https://segmentfault.com/a/1190000007875949

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    存储过程 游标 有用
    Spring框架IOC容器和AOP解析 非常 有用
    业务逻辑;完成根据自动分单结果来决定进行的相关业务处理
    业务逻辑:完成基于分区关键字匹配的自动分单业务逻辑
    业务逻辑:完成基于CRM地址完全匹配的自动分单业务逻辑
    业务逻辑:完成客户下单后前台系统的数据处理并调用后台系统服务处理业务 webservice接口调用 有用
    Spring IOC 少
    Spring IOC 巨多 非常 有用
    Spring ioc
    LeetCode -- Remove Element
  • 原文地址:https://www.cnblogs.com/wq242424/p/8042583.html
Copyright © 2011-2022 走看看