【docker】Docker里面文件的上传和下载

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值