docker ps
- Lists containers.python
docker logs
- Shows us the standard output of a container.web
docker stop
- Stops running containers.
docker
// -P告訴Docker映射所須要的端口到本地主機
ubuntu
$ docker run -d -P training/webapp python app.py
// -l顯示詳細信息
$ docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse
//Docker將容器的5000端口映射到主機的49155端口,此時能夠經過localhost:49155訪問網站了
app
//上面的-P標籤至關於-p 5000,如下是自定義端口映射關係,將容器的5000端口映射到主機的5000端口
webapp
$ docker run -d -p 5000:5000 training/webapp python app.py
//查看容器ubuntu:14.04的5000端口映射主機的端口
tcp
$ docker port CONTAINERID[3~4] 5000 0.0.0.0:49155
//查看容器ubuntu:14.04的輸出,-f 的效果相似tail -f網站
$ docker logs -f CONTAINERID[3~4] * Running on http://0.0.0.0:5000/ 10.0.2.2 - - [23/May/2014 20:16:31] "GET / HTTP/1.1" 200 - 10.0.2.2 - - [23/May/2014 20:16:31] "GET /favicon.ico HTTP/1.1" 404 -
//查看容器的
spa
$ docker top CONTAINERID[3~4] PID USER COMMAND 854 root python app.py
//查看容器對應的IP
luoo@PS:~$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' 3589
172.17.0.8
//中止容器
$ docker stop CONTAINERID[3~4] //刪除容器$ docker rm CONTAINERID[3~4]