CentOS 7 物理機訪問虛擬機中docker的nginx服務

環境:物理機 192.168.10.一、虛擬機 192.168.10.13一、docker 172.17.0.1php

啓動dockerhtml

[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

檢索nginxlinux

[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鏡像nginx

[root@localhost ~]# docker pull nginx

拉取慢可添加源web

[root@localhost ~]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}

啓動容器,運行nginx鏡像docker

[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

  

驗證是否成功運行json

[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>

物理機輸入虛擬機地址訪問centos

相關文章
相關標籤/搜索