• 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

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    node的function函数和路由代码的小例子
    关于node回调函数中同步和异步操作的理解
    node初学
    CTF知识点总结(二)
    知识图谱
    论文笔记 无监督与混合IDS
    CTF知识点总结(一)
    论文笔记 网络安全图谱以及溯源算法
    攻防世界 wtf.sh-150
    攻防世界 Web_php_wrong_nginx_config
  • 原文地址:https://www.cnblogs.com/wq242424/p/8042583.html
Copyright © 2020-2023  润新知