Skip to content
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 常用命令 #1

Open
liuweifeng opened this issue Feb 13, 2016 · 0 comments
Open

Docker 常用命令 #1

liuweifeng opened this issue Feb 13, 2016 · 0 comments

Comments

@liuweifeng
Copy link
Owner

列出所有镜像(images)

docker images

列出正在运行的容器(containers)

docker ps

列出所有的容器

docker ps -a

下载centos镜像

docker pull centos

运行centos镜像

docker run -i -t centos /bin/bash
docker run -d -p 80:80   hjue/centos-lamp

运行容器并做http端口转发
docker run -i -t -p :80 LAMP /bin/bash
建立映像文件
docker build --rm=true -t hjue/lamp .

–rm 选项是告诉Docker在构建完成后删除临时的Container,Dockerfile的每一行指令都会创建一个临时的Container,一般你是不需要这些临时生成的Container。

提交你的变更,并且把容器保存成镜像,命名为 mynewimage.3a09b2588478为容器的ID.

docker commit 3a09b2588478 mynewimage

把 mynewimage 镜像保存成 tar 文件

docker save mynewimage | bzip2 -9 -c> /home/save.tar.bz2

加载 mynewimage 镜像

bzip2 -d -c < /home/save.tar.bz2 | docker load  

删除所有容器

docker rm `docker ps -a -q` 

删除镜像

docker rmi [image-id]

帮助

docker run --help   

导出Image

docker export <CONTAINER ID> > /home/export.tar

导入Image镜像

cat /home/export.tar | sudo docker import - mynewimage

来源 http://www.hjue.me/post/docker-command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant