无法使用私有域连接到 Lightsail 中的 AWS 容器服务

Can't connect to an AWS container service in Lightsail using it's private domain

我在安装了 nginx (1.18.0) 的 AWS Lightsail 上创建了一个 Ubuntu (20.04 LTS) 实例。我还成功地将 docker 图像发布到 AWS Lightsail 容器服务,当启用 public 端点时,它可以正常工作。但是,我不想将此服务公开给 public,而是通过我的 Ubuntu 实例上的反向代理将流量路由到它。

我的问题是,当我尝试从我的 Ubuntu 实例卷曲容器服务的私有域 (.service.local:) 时,我得到 Could not resolve host servicename.service.local。根据 Lightsail docs(“私有域”部分),我的“与您的服务位于同一 AWS 区域的 Lightsail 资源”应该可以访问它。

我对网络还很陌生,非常感谢您提供一些意见。为了从我的实例访问此服务,是否还需要配置任何其他内容?

我已验证的内容:

非常感谢!

我刚 运行 遇到了同样的问题。我启动了两个实例,一个使用 Amazon Linux 2,一个使用 Ubuntu 20.04。 AL2实例可以通过域名解析访问一个容器服务:

[ec2-user@ip-172-26-0-176 ~]$ host nginx.service.local
nginx.service.local has address 172.26.17.185
[ec2-user@ip-172-26-0-176 ~]$ curl http://nginx.service.local/
<!DOCTYPE html>
...

Ubuntu 实例不能。

有用的是删除 Ubuntu 实例上的 /etc/resolv.conf,并将其替换为 AL2 实例中的那个:

[ec2-user@ip-172-26-0-176 ~]$ cat /etc/resolv.conf 
; generated by /usr/sbin/dhclient-script
search eu-central-1.compute.internal
options timeout:2 attempts:5
nameserver 172.26.0.2

它有效,但感觉不是一个特别干净的解决方案,因为它会覆盖 Ubuntu 的 systemd 管理的 resolv.conf。