docker容器命令大全
docker安装nginx:
[root@localhost pingxixi]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
bf5952930446: Pull complete
cb9a6de05e5a: Pull complete
9513ea0afb93: Pull complete
b49ea07d2e93: Pull complete
a5e4a503d449: Pull complete
Digest: sha256:b0ad43f7ee5edbc0effbc14645ae7055e21bc1973aee5150745632a24a752661
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
查看自己的镜像文件,就可以查看到自己的nginx镜像文件
[root@localhost pingxixi]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost pingxixi]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4bb46517cac3 2 days ago 133MB
centos latest 0d120b6ccaa8 5 days ago 215MB
启动nginx
[root@localhost pingxixi]# docker run -d --name nginx01 -p 3344:80 nginx
8e5ea9df9da55c43f6bbc9a3aea7aa1d5685016e13552c1ede2ee994a438deb4
-d以后台的方式运行
–name nginx01 给这个nginx取名字叫nginx01
–p:3344:80 暴露端口, 3344是服务器端口,加上容器的端口80
docker images显示所有镜像获取
查看nginx是否启动成功:
[root@localhost pingxixi]# curl localhost:3344
便可以获取到首页html代码
如果linux系统防火墙里面3344端口未开。那么需要开启3344端口
这个时候就可以在windows浏览器中访问了


本文详细介绍了如何使用Docker安装和配置Nginx,包括拉取镜像、查看镜像、启动容器并设置端口映射。通过具体命令演示,帮助读者快速掌握Docker环境下Nginx的部署流程。
1430

被折叠的 条评论
为什么被折叠?



