关于如何安装docker可以参考这篇文章:http://www.runoob.com/docker/ubuntu-docker-install.html
安装好docker之后,按照上面的文章提示配置镜像加速。
然后运行“docker run hello-world”。第一次会提醒找不到镜像“hello-world”,没关系,它会自动去下载的。
下载完之后会看到“Hello from Docker!”,也就说明你的docker安装是可以用的。
命令运行记录:
shenqh@shenqh-virtual-machine:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
shenqh@shenqh-virtual-machine:~$
查看web应用服务器,下载安装完之后在浏览器之后根据ip和端口号输入访问地址,浏览器会打印“Hello world!”,如果安装失败,你将看不到端口号信息,如果根据网上别人的端口号输入网址是打不开的。
运行“docker pull training/webapp”和“docker run -d -P training/webapp python app.py”安装应用。
运行“docker ps”,会看见command为"python app.py"的docker的“PORTS”是有数据的,我的是“0.0.0.0:32768->5000/tcp”,那么我在浏览器中访问“http://ip:32768/”就看见浏览器打印的“Hello world!”。
命令运行记录:
shenqh@shenqh-virtual-machine:~$ docker pull training/webapp
Using default tag: latest
latest: Pulling from training/webapp
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
10bbbc0fc0ff: Pull complete
fca59b508e9f: Pull complete
e7ae2541b15b: Downloading
9dd97ef58ce9: Download complete
a4c1b0cb7af7: Download complete
Get https://registry-1.docker.io/v2/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
shenqh@shenqh-virtual-machine:~$ docker run -d -P training/webapp python app.py
Unable to find image 'training/webapp:latest' locally
latest: Pulling from training/webapp
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
10bbbc0fc0ff: Pull complete
fca59b508e9f: Pull complete
e7ae2541b15b: Pull complete
9dd97ef58ce9: Pull complete
a4c1b0cb7af7: Pull complete
Digest: sha256:06e9c1983bd6d5db5fba376ccd63bfa529e8d02f23d5079b8f74a616308fb11d
Status: Downloaded newer image for training/webapp:latest
fea442b8b296049f474ca0f1634475e3a182217a32eeab649ea6644e21b49921
shenqh@shenqh-virtual-machine:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fea442b8b296 training/webapp "python app.py" 19 seconds ago Up 14 seconds 0.0.0.0:32768->5000/tcp jovial_albattani
shenqh@shenqh-virtual-machine:~$