[英]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.