无法访问 ec2 上的本地主机来访问 pgAdmin 容器

问题描述 投票:0回答:1

这是我的步骤--

  1. 在我的公共子网中创建了一个启用了公共地址的 ec2。
  2. 在附加到上述 ec2 的安全组上允许具有所有端口的公共 IP 地址作为入站规则。
  3. 安装了docker
  4. docker pull dpage/pgadmin4 --- 创建了镜像
5. docker run -p 80:80 \
    -e '[email protected]' \
    -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
    -d dpage/pgadmin4
  1. docker ps 确认容器正在运行

  2. curl http://localhost 或 http:127.0.0.1 失败

  3. 从浏览器 public-ip:80 也失败(超时)

真的很困扰我,感谢任何帮助/指导来解决。

postgresql amazon-web-services docker amazon-ec2 pgadmin-4
1个回答
0
投票

这听起来应该可以正常工作,但以下是我创建相同设置的步骤。

  1. 启动 EC2 实例。
  2. 附加适当的安全组。我假设您的 EC2 实例上的安全组如下所示:

这将允许来自任何外部 IP 的端口 22 (SSH)、80 (HTTP) 和 443 (HTTPS) 上的入站连接。

  1. 创建与 EC2 实例的 SSH 连接。接下来的几个步骤是通过 SSH 连接完成的。
  2. sudo apt update
    sudo apt install docker.io
  3. 启动容器:
docker run -p 80:80 \
    -e '[email protected]' \
    -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
    -d dpage/pgadmin4
  1. 检查容器是否正在运行。
$ docker ps
CONTAINER ID   IMAGE            COMMAND            CREATED         STATUS         PORTS                                        NAMES
1bbf1925d84a   dpage/pgadmin4   "/entrypoint.sh"   8 minutes ago   Up 8 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp   xenodochial_pike
  1. 检查本地连接。
$ curl http://localhost
<!doctype html>
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="/login?next=%2F">/login?next=%2F</a>. If not, click the link.
$ curl http://127.0.0.1
<!doctype html>
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="/login?next=%2F">/login?next=%2F</a>. If not, click the link.
  1. 检查远程连接。尝试从本地计算机上的浏览器进行连接。我的测试 EC2 实例的公共 IP 是 18.130.230.222,因此我访问 http://18.130.230.222.

© www.soinside.com 2019 - 2024. All rights reserved.