ubuntu 16.04安装docker
~# apt-get install docker.io
ubuntu启动docker服务
~# service docker start
搜索docker映像
~# docker search http
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 1830 [OK]
haproxy HAProxy - The Reliable, High Performance T... 1001 [OK]
......还有很多结果显示, 略
下载httpd的docker映像
~# docker pull httpd
......等待下载完毕......
查看本机docker映像
~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest 94af1f614752 4 days ago 178 MB
运行httpd的docker映像成为容器
~# docker run -it -d -p 80:80 --name datahttpd -v /data/:/usr/local/apache2/htdocs/ httpd
~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6bd2f6c6dfc httpd "httpd-foreground" 21 minutes ago Up 21 minutes 0.0.0.0:80->80/tcp datahttpd
-i 交互
-t 控制台
-d 后台运行
-p 本机端口:映射为本docker映像的端口
--name 为docker容器起的名称
-v 本机路径:映射为本docker映像的路径
验证httpd服务
ubuntu 16.04安装docker
~# apt-get install docker.io