简体   繁体   English

如何访问在 docker 容器上运行的 wordpress?

[英]How to access wordpress running on a docker container?

There is simply an ubuntu server with docker installed.只有一个安装了 docker 的 ubuntu 服务器。 Pulling wordpress docker image using使用拉取 wordpress docker 图像

`$ docker pull wordpress`.

Then running the container using然后使用运行容器

$ docker run --name my-wp -p 8080 -h 192.168.1.11 -d wordpress 

Checking the logs:检查日志:

$ docker logs my-wp
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
[Mon Mar 30 10:42:10.499346 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 
(Debian) PHP/7.3.16 configured -- resuming normal operations
[Mon Mar 30 10:42:10.499390 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D 
FOREGROUND'

Checking running container and port number:检查正在运行的容器和端口号:

$ docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                             NAMES
9a06a4bb7ce5        wordpress           "docker-entrypoint.s…"   22 minutes ago      Up 22 minutes       80/tcp, 0.0.0.0:32769->8080/tcp   my-wp

Now I tried to access wordpress using ip 192.168.1.11:8080 and 192.168.1.11:32769 and 127.0.0.1:8080 and 127.0.0.1:32769.现在我尝试使用 ip 192.168.1.11:8080 和 192.168.1.11:32769 和 127.0.0.1:8080 和 127.0.0.1:32769 访问 wordpress。 None could open the wordpress page.没有人可以打开 wordpress 页面。 Note that I already have a webserver running on port 80 on my host OS.请注意,我已经在主机操作系统的端口 80 上运行了一个网络服务器。

Any ideas on how to access wordpress web page?关于如何访问 wordpress 网页的任何想法?

Thanks to David Maze, whose comment helped to realise that port remapping is necessary.感谢 David Maze,他的评论有助于意识到端口重新映射是必要的。 With the following command, I map port 80 of the container to port 8080 of the host, and now wordpress is accessible.通过以下命令,我将容器的80端口映射到主机的8080端口,现在wordpress可以访问了。

$ docker run --name my-wp -p 8080:80 -d wordpress

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

相关问题 如何从同一台 wordpress 服务器(运行在同一台服务器上的 docker 容器)访问运行在 docker 容器中的数据库? - How to access the database running in a docker container from the same wordpress server(docker container running in same server)? 如何为在 docker 容器中运行的 wordpress 站点配置 Ngix? - How to configure Ngix for wordpress site running ina docker container? 访问正在运行的 docker 容器文件系统 - Access running docker container filesystem 在docker中运行时如何访问wordpress mysql数据库? - How do you access the wordpress mysql database when running it in docker? 无法访问 Docker 容器中安装的 Wordpress - Can't access Wordpress installed in Docker container docker-compose mysql 容器拒绝访问 wordpress 容器 - docker-compose mysql container denies access to wordpress container 运行 Wordpress Docker 容器时启用 EXIF 支持 - Enable EXIF support when running Wordpress Docker container Docker中的WordPress容器如何连接域名? - How to connect domain name with WordPress container in Docker? 如何将 apache2 链接到 wordpress docker 容器? - How to link apache2 to a wordpress docker container? 无法通过 HTTPS 访问 WordPress docker 容器的静态文件 - Cannot access static files of WordPress docker container over HTTPS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM