设为首页 收藏本站
查看: 872|回复: 0

[经验分享] docker里安装ubuntu

[复制链接]
发表于 2017-11-21 16:49:02 | 显示全部楼层 |阅读模式
使用 Ubuntu 官方镜像
  Ubuntu 相关的镜像有很多,这里使用 -s 10 参数,只搜索那些被收藏 10 次以上的镜像



$ docker search -s 10 ubuntu
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                               Official Ubuntu base image                      840       [OK]
dockerfile/ubuntu                    Trusted automated Ubuntu (http://www.ubunt...   30                   [OK]
crashsystems/gitlab-docker           A trusted, regularly updated build of GitL...   20                   [OK]
sylvainlasnier/memcached             This is a Memcached 1.4.14 docker images b...   16                   [OK]
ubuntu-upstart                       Upstart is an event-based replacement for ...   16        [OK]
mbentley/ubuntu-django-uwsgi-nginx                                                   16                   [OK]
ansible/ubuntu14.04-ansible          Ubuntu 14.04 LTS with ansible                   15                   [OK]
clue/ttrss                           The Tiny Tiny RSS feed reader allows you t...   14                   [OK]
dockerfile/ubuntu-desktop            Trusted automated Ubuntu Desktop (LXDE) (h...   14                   [OK]
tutum/ubuntu                         Ubuntu image with SSH access. For the root...   12                   [OK]
  注意,Docker 1.12 版本中已经不支持 --stars 参数,则可以使用 -f stars=N 参数。
  根据搜索出来的结果,读者可以自行选择下载镜像并使用。
  下面以 ubuntu 14.04 为例,演示如何使用该镜像安装一些常用软件。
  首先使用 -ti 参数启动容器,登录 bash,查看 ubuntu 的发行版本号。

Ubuntu

基本信息
  Ubuntu 是流行的 Linux 发行版,其自带软件版本往往较新一些。
  该仓库位于 https://hub.docker.com/_/ubuntu/ ,提供了 Ubuntu 从 12.04 ~ 16.10 各个版本的镜像。

使用方法
  默认会启动一个最小化的 Ubuntu 环境。



$ docker run --name some-ubuntu -i -t ubuntu
root@523c70904d54:/#
  当试图直接使用 apt-get 安装一个软件的时候,会提示 E: Unable to locate package。



1 root@7d93de07bf76:/# apt-get install curl
2 Reading package lists... Done
3 Building dependency tree
4 Reading state information... Done
5 E: Unable to locate package curl
  这并非系统不支持 apt-get 命令。Docker 镜像在制作时为了精简清除了 apt 仓库信息,因此需要先执行 apt-get update 命令来更新仓库信息。更新信息后即可成功通过 apt-get 命令来安装软件。



root@7d93de07bf76:/# apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Ign http://archive.ubuntu.com trusty-security InRelease
Ign http://archive.ubuntu.com trusty-proposed InRelease
Get:1 http://archive.ubuntu.com trusty Release.gpg [933 B]
...
  首先,安装 curl 工具。



root@7d93de07bf76:/# apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
ca-certificates krb5-locales libasn1-8-heimdal libcurl3 libgssapi-krb5-2
libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
libheimntlm0-heimdal libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1
libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2
libroken18-heimdal librtmp0 libsasl2-2 libsasl2-modules libsasl2-modules-db
libwind0-heimdal openssl
...
root@7d93de07bf76:/# curl
curl: try 'curl --help' or 'curl --manual' for more information
  接下来,再安装 apache 服务。



root@7d93de07bf76:/# apt-get install -y apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libxml2 sgml-base ssl-cert xml-core
...
  启动这个 apache 服务,然后使用 curl 来测试本地访问。



root@7d93de07bf76:/# service apache2 start
* Starting web server apache2                                                                                                                               AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
*
root@7d93de07bf76:/# curl 127.0.0.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Modified from the Debian original for Ubuntu
Last updated: 2014-03-19
See: https://launchpad.net/bugs/1288690
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache2 Ubuntu Default Page: It works</title>
<style type="text/css" media="screen">
...
  配合使用 -p 参数对外映射服务端口,可以允许容器外来访问该服务。

相关资源


  • Debian 官网:https://www.debian.org/
  • Neuro Debian 官网:http://neuro.debian.net/
  • Debian 官方仓库:https://github.com/Debian
  • Debian 官方镜像:https://hub.docker.com/_/debian/
  • Debian 官方镜像仓库:https://github.com/tianon/docker-brew-debian/
  • Ubuntu 官网:http://www.ubuntu.org.cn/global
  • Ubuntu 官方仓库:https://github.com/ubuntu
  • Ubuntu 官方镜像:https://hub.docker.com/_/ubuntu/
  • Ubuntu 官方镜像仓库:https://github.com/tianon/docker-brew-ubuntu-core

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-409255-1-1.html 上篇帖子: 哪种Linux发行版适合程序员做开发? 下篇帖子: Linux 虚拟机安装后的配置和一些命令符笔记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表