docker三种方式运行application
(1)、一次性运行
docker run ubuntu:14.04 /bin/echo 'Hello world'
登录到container ubuntu14.04 运行命令/bin/echo 'Hello world'
docker run contianername command
当你使用一个image时,docker首先从本地查找,若没有,则从docker Hub下载
命令执行完,contianer stop
(2)、交互式运行
docker run -t -i ubuntu:14.04 /bin/bash
开启终端进行交互,联网的情况下,可以自己使用命令安装程序
-t and -i. The -t flag assigns a pseudo-tty or terminal inside our new container
and the -i flag allows us to make an interactive connection by grabbing the standard in (STDIN) of the container.
(3)、后台运行
docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147
-d 表示后台运行
/bin/sh -c "while true; do echo hello world; sleep 1; done"为运行命令,循环输出hello world
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147为返回的container id值
使用docker ps 查看运行中的container可以查看容器的id name等属性
使用docker logs container_name 查看指定容器名的输出
使用docker stop container_name 停止指定的容器
(1)、一次性运行
docker run ubuntu:14.04 /bin/echo 'Hello world'
登录到container ubuntu14.04 运行命令/bin/echo 'Hello world'
docker run contianername command
当你使用一个image时,docker首先从本地查找,若没有,则从docker Hub下载
命令执行完,contianer stop
(2)、交互式运行
docker run -t -i ubuntu:14.04 /bin/bash
开启终端进行交互,联网的情况下,可以自己使用命令安装程序
-t and -i. The -t flag assigns a pseudo-tty or terminal inside our new container
and the -i flag allows us to make an interactive connection by grabbing the standard in (STDIN) of the container.
(3)、后台运行
docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147
-d 表示后台运行
/bin/sh -c "while true; do echo hello world; sleep 1; done"为运行命令,循环输出hello world
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147为返回的container id值
使用docker ps 查看运行中的container可以查看容器的id name等属性
使用docker logs container_name 查看指定容器名的输出
使用docker stop container_name 停止指定的容器