上一篇中涉及了
docker ps - Lists containers.
docker logs - Shows us the standard output of a container.
docker stop - Stops running containers.
1、Running a Web Application in Docker
docker run -d -P training/webapp python app.py
-d 表示后台运行
-p 表示映射webapp监听的端口到docker host的端口
training/webapp为装有webapp的image
python app.py为image中运行的命令
P flag is new and tells Docker to map any required network ports inside our container to our host. This lets us view our web application.
We've specified an image: training/webapp. This image is a pre-built image we've created that contains a simple Python Flask web application.
Lastly, we've specified a command for our container to run: python app.py. This launches our web application.
2、查看运行中的container
docker ps -l
-l表示 查看容器细节
-a表示 查看所以容器,包括stop状态
docker run -d -p 5000:5000 training/webapp python app.py
-p 5000:5000 指定映射端口
docker port nostalgic_morse 5000
快捷查看端口映射,nostalgic_morse为指定的container name
docker logs -f nostalgic_morse
查看容器nostalgic_morse的日志,-f类似tail -f中的-f
查看web容器中的进程
docker top nostalgic_morse
查看web容器属性
docker inspect nostalgic_morse
查看web容器指定的属性
docker inspect -f '{{ .NetworkSettings.IPAddress }}' nostalgic_morse
3、对容器的操作
(1)、停止运行中的容器
docker stop nostalgic_morse
(2)、启动容器运行
docker rm nostalgic_morse
docker ps - Lists containers.
docker logs - Shows us the standard output of a container.
docker stop - Stops running containers.
1、Running a Web Application in Docker
docker run -d -P training/webapp python app.py
-d 表示后台运行
-p 表示映射webapp监听的端口到docker host的端口
training/webapp为装有webapp的image
python app.py为image中运行的命令
P flag is new and tells Docker to map any required network ports inside our container to our host. This lets us view our web application.
We've specified an image: training/webapp. This image is a pre-built image we've created that contains a simple Python Flask web application.
Lastly, we've specified a command for our container to run: python app.py. This launches our web application.
2、查看运行中的container
docker ps -l
-l表示 查看容器细节
-a表示 查看所以容器,包括stop状态
docker run -d -p 5000:5000 training/webapp python app.py
-p 5000:5000 指定映射端口
docker port nostalgic_morse 5000
快捷查看端口映射,nostalgic_morse为指定的container name
docker logs -f nostalgic_morse
查看容器nostalgic_morse的日志,-f类似tail -f中的-f
查看web容器中的进程
docker top nostalgic_morse
查看web容器属性
docker inspect nostalgic_morse
查看web容器指定的属性
docker inspect -f '{{ .NetworkSettings.IPAddress }}' nostalgic_morse
3、对容器的操作
(1)、停止运行中的容器
docker stop nostalgic_morse
(2)、启动容器运行
docker start nostalgic_morse
(3)、删除容器docker rm nostalgic_morse
注:删除运行中的容器,需要先停止容器的运行
(4)、进入正在运行的容器
docker attach containterid/containtername