创建一个带apache2的ubunt镜像
利用之前的命令我们先搜索下,目前在dockerHub上ubunt镜像
stormfast@ubuntu:/usr/local$ docker search -f stars=20 ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 6097 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 89 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 74 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --components... 30 [OK]
torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 28 [OK]
这里你也许发现了,我们并没有使用先前的命令==docker search -s 20 ubuntu==
因为Docker1.12之后已经不再支持–stars命令了
给一个基本的Ubuntu镜像安装一些常用的软件
- 启动一个ubuntu镜像,并查看版本
stormfast@ubuntu:/usr/local$ docker run -it ubuntu:14.04
root@8f1b28c062cb:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
- 安装软件
root@8f1b28c062cb:/# apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
提示我们无法安装curl,这是为什么?这是因为Docker镜像为了精简,省去了apt仓库信息,我们需要使用apt-get update 命令更新仓库信息,才能更新软件
apt-get update
apt-get install curl
apt-get install apache2
- 制作镜像
退出容器,执行==dockercommitCONTAINER[REPOSITORY[:TAG]]==
命令打包已生成好的镜像
4. 创建并启动容器
docker run -it -p 80:80 apache2/ubunt:1.0
启动apache2
root@045127b147d7:/# 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
*
访问:127.0.0.1看页面即可