@MiloXia
2015-04-01T11:52:37.000000Z
字数 1326
阅读 1937
docker
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
sudo docker run -t -i -p 80:80 -p 8125:8125/udp -p 8126:8126 kamon/grafana_graphite:latest
sudo docker run -t -i -p 80:80 -p 8125:8125/udp -p 8126:8126 kamon/grafana_graphite:latest /bin/bash
#输入 exit 退出
sudo docker ps //获取容器的NAMES
sudo docker attach kamon-grafana-dashboard
sudo docker stop container-name/container-id
sudo docker ps -a
sudo docker start -a -i container-name/container-id
sudo docker restart -t container-name/container-id //不加-t 立即重启
sudo docker images
sudo docker rm container-name/container-id
1.Dockerfile
Dockerfile 基本的语法是
#:来注释
FROM:告诉 Docker 使用哪个镜像作为基础
MAINTAINER:维护者的信息
RUN:创建中运行指令,比如安装一个软件包,在这里使用 apt-get 来安装了一些软件
ADD:复制本地文件到镜像,比如配置文件
EXPOSE:对外开放的端口
CMD:描述容器启动后运行的程序
# This is a comment
FROM ubuntu:14.04
MAINTAINER Docker Newbee <newbee@docker.com>
RUN apt-get -qq update
RUN apt-get -qqy install ruby ruby-dev
RUN gem install sinatra
# put my local web site in myApp folder to /var/www
ADD myApp /var/www
# expose httpd port
EXPOSE 80
# the command to run
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
sudo docker build -t="kamon/grafana_graphite:v2"
#-t 添加Tag
[细节]:http://dockerpool.com/static/books/docker_practice/dockerfile/README.html
sudo docker ps -a //获得CONTAINER ID (不是IMAGE ID)
sudo docker export 7691a814370e > ubuntu.tar
cat ubuntu.tar | sudo docker import - test/buntu:v1.0
docker load < /tmp/mynewimage.tar