简体   繁体   English

无法访问 Docker 容器中安装的 Wordpress

[英]Can't access Wordpress installed in Docker container

New to Docker and not fully understand it, bear with me if my expressions are confusing/wrong. Docker 新手并且不完全理解它,如果我的表达令人困惑/错误,请耐心等待。 I have a Ubuntu box on Azure with public IP address assigned.我在 Azure 上有一个分配了公共 IP 地址的 Ubuntu 机器。 Then I putty into the box and install apache, php.然后我把腻子放进盒子里并安装apache、php。 I also installed Docker and Docker-compose.我还安装了 Docker 和 Docker-compose。 I am following this official tutorial to install wordpress(on port 8000).我正在按照此官方教程安装 wordpress(在端口 8000 上)。 When installation finishes I can see the default apache ubunto page at http://xxx.xxx.xxx.xxx , but I am unable to access the website at http://xxx.xxx.xxx.xxx:8000 .安装完成后,我可以在http://xxx.xxx.xxx.xxx看到默认的 apache ubunto 页面,但我无法访问http://xxx.xxx.xxx.xxx:8000的网站。 What's the reason for not being able to access it?无法访问它的原因是什么? I can't find any relevant tutorial as most tutorials are doing it on localhost hence not referable.我找不到任何相关教程,因为大多数教程都是在本地主机上进行的,因此不可参考。 This is my docker-compose.yml file:这是我的 docker-compose.yml 文件:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:

docker ps outputs following: docker ps 输出如下:

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                            NAMES
07d669b9f95e        phpmyadmin/phpmyadmin   "/run.sh supervisord…"   10 hours ago        Up 10 hours         9000/tcp, 0.0.0.0:8080->80/tcp   wp_phpmyadmin_1
5ff939494739        wordpress:latest        "docker-entrypoint.s…"   11 hours ago        Up 11 hours         0.0.0.0:8000->80/tcp             wp_wordpress_1
479826f7cfb8        mysql:5.7               "docker-entrypoint.s…"   11 hours ago        Up 11 hours         3306/tcp, 33060/tcp              wp_db_1

Solution: At last I managed to make it work by opening up the port in Azure.解决方案:最后我设法通过在 Azure 中打开端口使其工作。

The problem is not with docker as long as the ports are exposed and you can see the content in the host machine只要端口公开并且您可以在主机中看到内容,问题就不在于docker

the problem is probably with the host machine, which should expose 8000 port问题可能出在主机上,它应该公开 8000 端口

i'm not familiar with Azure, but i'm guessing port 80 is exposed by default, so try changing我对 Azure 不熟悉,但我猜默认情况下会暴露 80 端口,因此请尝试更改

 ports:
   - "8000:80"

to

 ports:
   - "80:80"

and call the machine using port 80 (which is http default)并使用端口 80(这是 http 默认)调用机器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Wordpress Docker 容器无法连接到数据库容器 - Wordpress Docker container can't connect to database container docker wordpress 容器无法连接到 mysql 容器 - docker wordpress container can't connect to mysql container docker wordpress容器无法连接到数据库容器 - docker wordpress container can't connect to database container 无法将 Docker Wordpress 容器连接到主机上的 MySQL - Can't connect Docker Wordpress container to MySQL on host 我安装了 Bitnami,然后安装了 XAMPP 服务器,无法访问 wordpress - I installed Bitnami and then XAMPP server, can't access wordpress 如何访问在 docker 容器上运行的 wordpress? - How to access wordpress running on a docker container? 无法访问网站,在 Docker Wordpress 中出现 Apache ServerName 错误 - Can't access website with Apache ServerName error in Docker Wordpress docker-compose mysql 容器拒绝访问 wordpress 容器 - docker-compose mysql container denies access to wordpress container 无法使用Docker Stack和Official Wordpress Docker映像访问运行中的服务 - Can't access running service using Docker Stack and Official Wordpress Docker image 看不到基于alpine linux的wordpress docker容器的盯着安装页面 - Can't see staring installation page of wordpress docker container based on alpine linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM