【Vegas原创】Docker安装Nginx,并配置端口转发

1,docker安装Nginx

[root@hecs-29489 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Already exists 
66b1c490df3f: Pull complete 
d0f91ae9b44c: Pull complete 
baf987068537: Pull complete 
6bbc76cbebeb: Pull complete 
32b766478bc2: Pull complete 
Digest: sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest


2,docker run Nginx,默认80

[root@hecs-29489 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    4cdc5dd7eaad   12 days ago   133MB
wordpress    latest    b77ea6f8ecf7   2 weeks ago   551MB
mysql        latest    5c62e459e087   3 weeks ago   556MB
[root@hecs-29489 ~]# docker run --name nginx -p 80:80 -d nginx
35a903217fb79e8bf0d8c7855b57d2d7be5fa873a887acd44c34b415d69cfb7c


3,进容器,改配置文件

[root@hecs-29489 ~]# docker exec -it nginx bash
root@35a903217fb7:/# apt-get update
Hit:1 http://security.debian.org/debian-security buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease                      
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Reading package lists... Done
root@35a903217fb7:/# apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libgpm2 vim-common vim-runtime xxd
Processing triggers for libc-bin (2.28-10) ...
root@35a903217fb7:/etc/nginx/conf.d# vi /etc/nginx/conf.d/default.conf

【Vegas原创】Docker安装Nginx,并配置端口转发

上一篇:NodeMCU GPIO与ESP8266的映照


下一篇:regeorg+proxyfier流量代理