New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker大杂烩 #2

Open
ma6174 opened this Issue Jul 5, 2014 · 0 comments

Comments

1 participant
@ma6174
Owner

ma6174 commented Jul 5, 2014

docker 启动

使用lxc方式启动可以方便进行管理控制

docker -d -e lxc -dns 8.8.8.8 -dns 8.8.4.4

使用Dockfile生成镜像

docker build -t tag_name --rm=true .

将container打tag

docker container_id tag_name

docker 启动一个实例

下面的命令将container的8080端口映射为主机的80端口,指定container_name,将主机目录挂载到container里面,启动时执行bash命令。

docker run -t -i -p 80:8080 --name container_name -v host_addr:container_addr  image_name /bin/bash

container管理

docker ps
ps -ef | grep 5531741b0ff0
sudo lxc-attach -n 5531741b0ff05a46c793b24bfaa2b33dba66cad29fe9926641fee98b6b3e24df

image备份和恢复

docker save test_2 | gzip > image.tar.gz
cat image.tar.gz | gzip -d | sudo docker load
cat image.tar.gz | gzip -d | sudo docker import - test_import

docker registery相关命令

docker tag ubuntu:12.04 10.0.0.6:5000/ubuntu
docker commit 797d1da068ce 10.0.0.6:5000/busybox:version2 -a ma6174 -m "rm aaaa"
docker push 10.0.0.6:5000/ubuntu
docker pull 10.0.0.6:5000/ubuntu
docker history 10.0.0.6:5000/busybox

宿主机器内核

内核版本一定要在3.8以上,不然容易出一些莫名其妙的问题,还有被提权的风险。

@ma6174 ma6174 added the docker label Jul 5, 2014

@ma6174 ma6174 changed the title from 总结一下docker常用命令 to docker大杂烩 Jul 6, 2014

@ma6174 ma6174 self-assigned this Aug 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment