Last active
August 29, 2015 14:04
Revisions
-
xiocode revised this gist
Jul 17, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,13 +16,14 @@ 4. 下载image: docker pull centos:centos6 5. 运行一个container: docker run -t -i centos /bin/bash 6. 后台运行一个container: docker -d run centos xxx 7. 端口映射到本地(OSX需要用VisualBox做,详见14): docker -d -p 10010:10010 centos webapp 8. 查看所有container: docker ps -a 9. 启动/停止一个container: docker start/stop container_id 10. 删除一个container: docker rm container_id 11. 删除一个image: docker rmi image_id 12. 通过Dockerfile创建一个image:<https://docs.docker.com/reference/builder/> 13. commit container 到image: docker commit -m 'update' -a 'author' container_id image_id/image_name 14. Mac下端口映射: VBoxManage controlvm boot2docker-vm natpf1 "ssdb,tcp,127.0.0.1,8888,,8888" ## 进阶用法 1. 绑定多了个container,组合成一个新的架构: -
xiocode created this gist
Jul 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ # Docker ## 安裝 <https://docs.docker.com/installation> 1. install visualbox 2. brew install docker boot2docker ## 基本命令 <https://docs.docker.com/reference/commandline/cli/> <https://docs.docker.com/reference/run/> 1. 启动 boot2docker: init && boot2docker up 2. 更新 boot2docker: download 3. 查看所有的images: docker images 4. 下载image: docker pull centos:centos6 5. 运行一个container: docker run -t -i centos /bin/bash 6. 后台运行一个container: docker -d run centos xxx 7. 绑定一个端口: docker -d -p 10010:10010 centos webapp 8. 查看所有container: docker ps -a 9. 启动/停止一个container: docker start/stop container_id 10. 删除一个container: docker rm container_id 11. 删除一个image: docker rmi image_id 12. 通过Dockerfile创建一个image:<https://docs.docker.com/reference/builder/> 13. commit container 到image: docker commit -m 'update' -a 'author' container_id image_id/image_name ## 进阶用法 1. 绑定多了个container,组合成一个新的架构: ``` sudo docker run --name redis -d xiocode/redis sudo docker run --link redis:db --name web -i -t ubuntu:12.10 /bin/bash $ env | grep DB_ Should return something similar to this with your values DB_NAME=/violet_wolf/db DB_PORT_6379_TCP_PORT=6379 DB_PORT=tcp://172.17.0.33:6379 DB_PORT_6379_TCP=tcp://172.17.0.33:6379 DB_PORT_6379_TCP_ADDR=172.17.0.33 DB_PORT_6379_TCP_PROTO=tcp $ redis-cli -h $DB_PORT_6379_TCP_ADDR $ redis 172.17.0.33:6379> .... ``` ## 实例 <https://docs.docker.com/examples/>