美文网首页Docker学习之路
Docker --- Debian/Ubuntu

Docker --- Debian/Ubuntu

作者: 李凈海 | 来源:发表于2019-03-12 14:05 被阅读0次
      Debian/Ubuntu
        Debian和Ubuntu都是目前较为流行的Debian系的服务器操作系统,在Docker Hub上都可以直接搜索到官方版。
    
    
      搜索Debian
        --------------------------------------------------------------------
        [docker@localhost]$ sudo docker search debian
        INDEX       NAME                                          DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
        docker.io   docker.io/ubuntu                              Ubuntu is a Debian-based Linux operating s...   7868      [OK]       
        docker.io   docker.io/debian                              Debian is a Linux distribution that's comp...   2626      [OK]       
        docker.io   docker.io/google/debian                                                                       53                   [OK]
        docker.io   docker.io/arm32v7/debian                      Debian is a Linux distribution that's comp...   36                   
        docker.io   docker.io/armhf/debian                        Debian is a Linux distribution that's comp...   31                   
        docker.io   docker.io/itscaro/debian-ssh                  debian:jessie                                   23                   [OK]
        ...
        --------------------------------------------------------------------
        
      搜索Ubuntu
        Ubuntu相关的镜像有很多,因此这里使用【-s】参数,只搜索那些被收藏10次以上的镜像。
        --------------------------------------------------------------------
        [docker@localhost ~]$ sudo docker search -s 10 ubuntu
        INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
        docker.io   docker.io/ubuntu                                                 Ubuntu is a Debian-based Linux operating s...   7868      [OK]       
        docker.io   docker.io/dorowu/ubuntu-desktop-lxde-vnc                         Ubuntu with openssh-server and NoVNC            190                  [OK]
        docker.io   docker.io/rastasheep/ubuntu-sshd                                 Dockerized SSH service, built on top of of...   156                  [OK]
        docker.io   docker.io/ansible/ubuntu14.04-ansible                            Ubuntu 14.04 LTS with ansible                   93                   [OK]
        docker.io   docker.io/ubuntu-upstart                                         Upstart is an event-based replacement for ...   87        [OK]       
        docker.io   docker.io/neurodebian                                            NeuroDebian provides neuroscience research...   50        [OK]       
        docker.io   docker.io/ubuntu-debootstrap                                     debootstrap --variant=minbase --components...   38        [OK]       
        docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          36                   [OK]
        docker.io   docker.io/nuagebec/ubuntu                                        Simple always updated Ubuntu docker images...   23                   [OK]
        docker.io   docker.io/tutum/ubuntu                                           Simple Ubuntu docker images with SSH access     18                   
        docker.io   docker.io/i386/ubuntu                                            Ubuntu is a Debian-based Linux operating s...   13                   
        docker.io   docker.io/ppc64le/ubuntu                                         Ubuntu is a Debian-based Linux operating s...   12                   
        docker.io   docker.io/1and1internet/ubuntu-16-apache-php-7.0                 ubuntu-16-apache-php-7.0                        10                   [OK]
        --------------------------------------------------------------------
        根据搜索出来的结果,用户可以自行选择下载镜像并使用。
        
        下面就以Ubuntu15.10为例,让我们进去一个Docker版的Ubuntu:15.10操作系统来体验一下。
        
        使用【-ti】参数进入,查看Ubuntu的版本号:
        --------------------------------------------------------------------
        [docker@localhost ~]$ sudo docker run -ti ubuntu:15.10 /bin/bash
        root@306a1f080fc5:/# cat /etc/os-release 
        NAME="Ubuntu"
        VERSION="15.10 (Wily Werewolf)"
        ID=ubuntu
        ID_LIKE=debian
        PRETTY_NAME="Ubuntu 15.10"
        VERSION_ID="15.10"
        HOME_URL="http://www.ubuntu.com/"
        SUPPORT_URL="http://help.ubuntu.com/"
        BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
        --------------------------------------------------------------------
        当我们试图安装一个curl软件的时候,会提示:Unable to locate package curl。因为,Docker镜像为了精简镜像容量,默认删除了这些信息,需要我们使用apt-get update命令更新一次,大家也可以自己编辑/etc/apt/sources.list文件,将默认的软件源更改为国内的源:  
        --------------------------------------------------------------------
        root@2c3967885444:/# apt-get install curl
        Reading package lists... Done
        Building dependency tree       
        Reading state information... Done
        E: Unable to locate package curl
        --------------------------------------------------------------------
        更新源之后就可以安装软件了:
        --------------------------------------------------------------------
        root@2c3967885444:/# apt-get update
        Ign http://archive.ubuntu.com vivid InRelease
        Ign http://archive.ubuntu.com vivid-updates InRelease
        Ign http://archive.ubuntu.com vivid-security InRelease
        Ign http://archive.ubuntu.com vivid Release.gpg
        Ign http://archive.ubuntu.com vivid-updates Release.gpg
        Ign http://archive.ubuntu.com vivid-security Release.gpg
        Ign http://archive.ubuntu.com vivid Release
        Ign http://archive.ubuntu.com vivid-updates Release
        Ign http://archive.ubuntu.com vivid-security Release
        ...
        root@2c3967885444:/# apt-get install curl
        Reading package lists... Done
        Building dependency tree       
        Reading state information... Done
        ...
        root@2c3967885444:/# curl 
        curl: try 'curl --help' or 'curl --manual' for more information
        --------------------------------------------------------------------
        接下来,我们来用curl访问百度网站(注意,这里我的是可以访问外网,如果有同学不能访问外网,可以安装apache来测试)。
        --------------------------------------------------------------------
        root@172e3d6f55b3:~# curl www.baidu.com
        <!DOCTYPE html>
        <!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> 
        ...
        --------------------------------------------------------------------
    
    

    相关文章

      网友评论

        本文标题:Docker --- Debian/Ubuntu

        本文链接:https://www.haomeiwen.com/subject/ygogpqtx.html