docker学习总结四

1. 创建容器

$ docker create -it ubuntu:latest
2. 启动容器
$ docker start 容器ID
3. 新建并启动容器
$ docker run -it ubuntu:16.04 /bin/bash
4. 守护态运行
$ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
5.停止容器
$ docker stop 容器id
6. 进入容器
$ docker exec -it 容器id /bin/bash
7. 删除容器
删除已经终止的容器
$ docker rm 容器id

删除正在运行的容器
$ docker run -d ubuntu:16.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
8. 导出容器
不管运行与否都可导出
$ docker export -o test_for_run.tar 容器id

$ docker export 容器id >test_for_stop.tar
9. 导入容器
$ docker import test_for_run.tar - test/ubuntu:dao.1

猜你喜欢

转载自blog.51cto.com/13670314/2327290
今日推荐