标签:
# 安装镜像
sudo docker pull ubuntu:12.04
# 镜像列表
sudo docker images
# 运行镜像
sudo docker run -t -i ubuntu:12.04 /bin/bash
# 运行镜像,如果这个镜像不存在,则直接从仓库中下载下来 然后退出用exit
sudo docker run -t -i training/sinatra /bin/bash
# 创建文件
mkdir sinatra
cd sinatra
touch Dockerfile
sudo docker build -t="ouruser/sinatra:v2" .
ADD:复制本地文件到镜像
EXPOSE:像外部开放端口
CMD:描述容器启动后运行的程序 例如
ADD myApp /var/www
# expose httpd port
EXPOSE 80
# the command to run
CMD ["/usr/sbin/apachectl","-D","FOREGROUND"]
# put my local web site in myApp folder to /var/www
sudo cat ubuntu-14.04 |docker import -ubuntu:14.04
# 删除
sudo docker rmi training/sinatra
# 从导出的本地文件再导入到本地镜像库
sudo docker load --input ubuntu_14.04.tar
FROM ubuntu:13.04
MAINTAINER examples@docker.com
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
# 安装 ssh、apache 和 supervisor
RUN apt-get install -y openssh-server apache2 supervisor
RUN mkdir -p /var/run/sshd
RUN mkdir -p /var/log/supervisor
# 创建ssh和supervisor服务这个农场运行所需要的目录
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 添加supervisord配置文件,并复制配置文件到对应目录
EXPOSE 22 80
CMD ["/usr/bin/supervisord"]
# supervisor 配置文件的内容
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
# 启动supervisor容器
sudo docker run -p 22 -p 80 -t -i test/supervisords
标签:
原文地址:http://www.cnblogs.com/sunhan/p/546dbd4b8a564ba82a88d962a0e33ab0.html