1.创建目录
--交互模式直接在容器里创建目录。
docker exec -it sspu_8004 mkdir -p /usr/share/nginx/html/file/
[root@es1 ~]# docker exec -it sspu_8004 mkdir -p /usr/share/nginx/html/file/
2.将本地文件传到容器
docker cp /data/soft/docker-20.10.16.tgz sspu_8004:/usr/share/nginx/html/file/
[root@es1 soft]# docker cp /data/soft/docker-20.10.16.tgz sspu_8004:/usr/share/nginx/html/file/
--通过网页可以直接下载。
http://192.168.1.7:8004/file/docker-20.10.16.tgz
3.docker容器的内容拷贝到本地。
docker cp sspu_8004:/usr/share/nginx/html/file/docker-20.10.16.tgz /tmp/
[root@es1 soft]# docker cp sspu_8004:/usr/share/nginx/html/file/docker-20.10.16.tgz /tmp/
[root@es1 soft]# ll /tmp/docker*
-rw-r--r-- 1 root root 64969189 Jul 2 12:00 /tmp/docker-20.10.16.tgz
4.curl 访问
docker ps --查看容器进程。
netstat -an|grep 8004
curl -l http://192.168.1.7:8004 --直接使用操作系统命令查看8001端口的页面。
curl -l http://172.17.0.2:80 --访问docker里面的页面。第一个容器是0.2,第二是0.3
docker exec -it sspu_8004 /bin/bash
[root@es1 soft]# netstat -an |grep 8004
tcp 0 0 0.0.0.0:8004 0.0.0.0:* LISTEN
tcp6 0 0 :::8004 :::* LISTEN
[root@es1 soft]# curl -l http://192.168.1.7:8004
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@es1 soft]# curl -l http://172.17.0.4:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>