zoukankan      html  css  js  c++  java
  • 004、运行第一个容器(2018-12-19 周三)

     
    按照CloudMan的教程,编写了一个自动安装docker的脚本(和教程中一样,基于ubuntu16.04)
     
    #!/bin/bash
     
    #    该脚本基于 Ubuntu 16.04 64位 操作系统
     
    #    设置主机名
    echo 'docker-lab' >/etc/hostname
    hostname docker-lab
     
    #    配置Ubuntu源
    cat >/etc/apt/sources.list << EOF
    deb http://mirrors.aliyun.com/ubuntu/ xenial main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
     
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
     
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
     
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
    EOF
     
    #    配置docker源
    apt-get -y install apt-transport-https ca-certificates curl software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    apt-get update
     
    #    安装docker
    apt-get -y install docker-ce
     
    #    配置docker加速器(https://www.daocloud.io/mirror),下面的加速链接已做加密处理,请自行申请自己的加速链接
    curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6c4b02a.m.daocloud.io
    systemctl restart docker.service
     
    #    测试docker是否安装成功
    docker run hello-world
     
     
    docker安装完毕后,运行一个httpd的容器体验一下
     
    root@docker-lab:~# docker run -d -p 80:80 httpd
    Unable to find image 'httpd:latest' locally
    latest: Pulling from library/httpd
    a5a6f2f73cd8: Pull complete
    ac13924397e3: Pull complete
    91b81769f14a: Pull complete
    fec7170426de: Pull complete
    992c7790d5f3: Pull complete
    Digest: sha256:9753aabc6b0b8cd0a39733ec13b7aad59e51069ce96d63c6617746272752738e
    Status: Downloaded newer image for httpd:latest
    60ca82f95a9db301d0c464ee627a813a57c0bdd3a4c1a9315e30eedd02b3b721
    root@docker-lab:~# curl http://127.0.0.1
    <html><body><h1>It works!</h1></body></html>
     
     
  • 相关阅读:
    crontab 移动日志-超越昨天的自己系列(12)
    java进程性能分析步骤-超越昨天的自己系列(11)
    Linux 使用 you-get 指令下载网页视频
    Git git rm和git rm --cached
    Git .gitignore中已添加文件路径,但仍未被忽略
    Android 系统添加SELinux权限
    git 删除目录及子目录下的同名文件
    Android 查看和修改网络mtu
    git 设置git用户名和邮箱,并生成秘钥
    RK3288 添加普通串口uart1和uart3
  • 原文地址:https://www.cnblogs.com/www1707/p/10146948.html
Copyright © 2011-2022 走看看