CentOS 7 物理机访问虚拟机中docker的nginx服务
环境:物理机 192.168.10.1、虚拟机 192.168.10.131、docker 172.17.0.1
启动docker
[root@localhost ~]# docker info Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [root@localhost ~]# systemctl start docker
[root@localhost ~]# docker info
检索nginx
[root@localhost ~]# docker search nginx INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/nginx Official build of Nginx. 12084 [OK] docker.io docker.io/jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 1674 [OK] docker.io docker.io/richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable ... 743 [OK] docker.io docker.io/linuxserver/nginx An Nginx container, brought to you by Linu... 79 docker.io docker.io/bitnami/nginx Bitnami nginx Docker Image 72 [OK] docker.io docker.io/tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rt... 58 [OK] docker.io docker.io/nginxdemos/hello NGINX webserver that serves a simple page ... 31 [OK] docker.io docker.io/jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 26 [OK] docker.io docker.io/jc21/nginx-proxy-manager Docker container for managing Nginx proxy ... 24 docker.io docker.io/nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 22 docker.io docker.io/privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & ... 18 [OK] docker.io docker.io/schmunk42/nginx-redirect A very simple container to redirect HTTP t... 17 [OK] docker.io docker.io/blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 12 [OK] docker.io docker.io/centos/nginx-18-centos7 Platform for running nginx 1.8 or building... 11 docker.io docker.io/centos/nginx-112-centos7 Platform for running nginx 1.12 or buildin... 10 docker.io docker.io/nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 9 docker.io docker.io/nginx/nginx-prometheus-exporter NGINX Prometheus Exporter 7 docker.io docker.io/1science/nginx Nginx Docker images that include Consul Te... 5 [OK] docker.io docker.io/sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats... 5 [OK] docker.io docker.io/mailu/nginx Mailu nginx frontend 4 [OK] docker.io docker.io/pebbletech/nginx-proxy nginx-proxy sets up a container running ng... 2 [OK] docker.io docker.io/travix/nginx NGinx reverse proxy 2 [OK] docker.io docker.io/ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 1 [OK] docker.io docker.io/centos/nginx-110-centos7 Platform for running nginx 1.10 or buildin... 0 docker.io docker.io/wodby/nginx Generic nginx 0 [OK]
拉取nginx镜像
[root@localhost ~]# docker pull nginx
拉取慢可添加源
[root@localhost ~]# vi /etc/docker/daemon.json
{ "registry-mirrors": ["http://hub-mirror.c.163.com"] }
启动容器,运行nginx镜像
[root@localhost ~]# docker run -p 80:80 -d nginx
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2c4cb516025a nginx "nginx -g 'daemon ..." 31 seconds ago Up 29 seconds 0.0.0.0:80->80/tcp wonderful_haibt
验证是否成功运行
[root@localhost ~]# curl http://localhost <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> 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>
物理机输入虚拟机地址访问
posted on 2019-10-22 16:21 Ra7ing安全实验室 阅读(1301) 评论(0) 编辑 收藏 举报