Docker入门讲解

1:容器重命名
[root@Docker ~]#docker run --name test_container -i -t centos /bin/bash
[root@3ba67c6cf3f8 /]# hostname
3ba67c6cf3f8
参数解析:
“--name”:定义新建容器的名字;
2:启动,重启,停止容器
[root@Docker ~]#docker start test_container/3ba67c6cf3f8
[root@Docker ~]#docker stop test_container/3ba67c6cf3f8
[root@Docker ~]#docker restart test_container/3ba67c6cf3f8
3.创建守护式容器
[root@Docker ~]#docker run --name deamon_dave -d centos /bin/bash "while true;do echo hello world; sleep 1; done"
4:查看日志(常用的格式)
[root@Docker ~]#docker logs --tail 10 -ft deamon_dave ("-t":表示加时间戳)
实例:
[root@Docker ~]#docker logs --tail 2 -ft nodejs
2015-06-26T02:15:21.520546751Z GET /LD_Process/plugins/process/table/Table_TableOutput.xml 304 1ms
2015-06-26T02:15:21.530719515Z GET /LD_Process/plugins/process/table/Table_TableOutput.xml 304 1ms
5:在容器内部运行进程
[root@Docker ~]#docker start -ti test_container /bin/bash
[root@Docker ~]#docker exec -d test_container touch /etc/new_config_file
6:查看容器的具体信息
[root@Docker ~]#docker inspect test_container

 

posted @ 2018-05-17 16:33  追逐新梦想  阅读(130)  评论(0编辑  收藏  举报