镜像名查看:
root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25fcbf6e953d hub.c.163.com/library/ubuntu "/bin/bash" 18 minutes ago Up 18 minutes 0.0.0.0:32772->80/tcp static_test
[root@localhost ~]# docker port static_test
80/tcp -> 0.0.0.0:32772
[root@localhost ~]# 可以看到容器的80端口映射到注解的32772端口。
通过curl访问创建的index.html文件:
[root@localhost ~]# curl http://127.0.0.1:32772/index.html
<html>
<body>
<h1>
this is the first docker static file
</h1>
</body>
</html>
[root@localhost ~]#也可以通过
docker inspect 容器名来查看容器的详细信息和ip 通过容器ip进行访问:
[root@localhost ~]# docker inspect static_test
其他信息省略
"IPAddress": "172.17.0.5",
[root@localhost ~]# curl http://172.17.0.5/index.html
<html>
<body>
<h1>
this is the first docker static file
</h1>
</body>
</html>
[root@localhost ~]# 当我们使用
docker stop 容器名停止这个容器后,再使用
docker start 容器名启动容器后,里面的nginx并没有启动。那么我们使用
docker exec 容器名 nginx来启动:
[root@localhost ~]# docker stop static_test
static_test
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b4f32bbe4a34 hub.c.163.com/library/ubuntu "/bin/bash" 41 hours ago Up 41 hours loving_brattain
d75a2d8c7822 xingguo/df_test1 "nginx -g 'daemon off" 2 days ago Up 2 days 0.0.0.0:32770->80/tcp df_nginx_web
959c0fc5d903 xingguo/commit_test1 "nginx -g 'daemon off" 2 days ago Up 2 days 0.0.0.0:32769->80/tcp nginx_test
[root@localhost ~]# docker start static_test
static_test
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25fcbf6e953d hub.c.163.com/library/ubuntu "/bin/bash" 29 minutes ago Up 2 seconds 0.0.0.0:32773->80/tcp static_test
b4f32bbe4a34 hub.c.163.com/library/ubuntu "/bin/bash" 41 hours ago Up 41 hours loving_brattain
d75a2d8c7822 xingguo/df_test1 "nginx -g 'daemon off" 2 days ago Up 2 days 0.0.0.0:32770->80/tcp df_nginx_web
959c0fc5d903 xingguo/commit_test1 "nginx -g 'daemon off" 2 days ago Up 2 days 0.0.0.0:32769->80/tcp nginx_test










