# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
lvnanhai66/httpd 1.0 d86219e12166 21 minutes ago 768MB
centos latest 5d0da3dc9764 10 months ago 231MB
[root@localhost ~]# docker run -itd --name web -p 80:80 lvnanhai66/httpd:1.0 //使用之前自己上传的镜像
d3c9f4c098a301e2999b7875eebe05f32c5a7cb7ab0c4ab050e81013509ac9bd
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d3c9f4c098a3 lvnanhai66/httpd:1.0 "/lnh.sh" 17 seconds ago Up 15 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp web
[root@localhost ~]# curl 192.168.222.250
<html><body><h1>It works!</h1></body></html>
访问:
通过储存卷挂载到容器里面进行访问
[root@localhost tushanbu]# ls //将源码包导入
html5大气医院网站源码 html5大气医院网站源码.zip
[root@localhost tushanbu]# mv html5大气医院网站源码/* .
//将里面的东西全部移动到当前目录
[root@localhost tushanbu]# ls
chuzhen.html index.html keshimx.html newslist.html zhuanjia.html
css jianjie.html keshiys.html pic
html5大气医院网站源码 jiuzhen.html kexue.html rongyu.html
html5大气医院网站源码.zip js kexuelist.html uploadfiles
images keshi.html news.html ys.html
[root@localhost tushanbu]# rm -f html5大气医院网站源码.zip
[root@localhost tushanbu]# rm -f html5大气医院网站源码
[root@localhost tushanbu]# ls
chuzhen.html jianjie.html keshimx.html news.html uploadfiles
css jiuzhen.html keshiys.html newslist.html ys.html
images js kexue.html pic zhuanjia.html
index.html keshi.html kexuelist.html rongyu.html
[root@localhost tushanbu]# pwd
/root/tushanbu
[root@localhost ~]# docker pull lvnanhai66/httpd:1.0
1.0: Pulling from lvnanhai66/httpd //拉取自己之前上传的镜像
a1d0c7532777: Already exists
3189de0706ae: Pull complete
Digest: sha256:f1f72415ed86142b951f34c6de6d68e5768c294d77f6f8b4b43e45846ed25149
Status: Downloaded newer image for lvnanhai66/httpd:1.0
docker.io/lvnanhai66/httpd:1.0
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
lvnanhai66/httpd 1.0 d86219e12166 4 hours ago 768MB
[root@localhost ~]# docker run -d --name web -v /root/tushanbu:/usr/local/apache/htdocs -p 80:80 d86219e12166
e1cebaa28e21132450172a32b6dfb406413d3e2b676f5baa4195b4b9c78427e9
访问:
上传刚刚制作的镜像
[root@localhost ~]# docker stop web
web
[root@localhost ~]# docker commit -a 'lnh <136@.com>' -c 'CMD ["/lnh.sh"]' -p web lvnanhai66/httpd:2.0
sha256:523de2557ebefbae1f648cd4932ef6d95de93388c363a3dccd3554f91129534f
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
lvnanhai66/httpd 2.0 523de2557ebe 8 seconds ago 768MB
lvnanhai66/httpd 1.0 d86219e12166 4 hours ago 768MB
[root@localhost ~]# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@localhost ~]# docker push lvnanhai66/httpd:2.0
The push refers to repository [docker.io/lvnanhai66/httpd]
b873763b4ca4: Pushed
0fabae23f82c: Layer already exists
74ddd0ec08fa: Layer already exists
2.0: digest: sha256:f8e25d4e1d8688526dfdff8919da43c667f708159ebcd3e7d6b5c9993f280ef6 size: 950
查看上传的镜像: