小编Neo*_*eok的帖子

Docker-Postgres和pgAdmin 4:连接被拒绝

与docker的新手,我正在尝试通过pgAdmin容器将localhost连接到postgres容器。

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                         NAMES
0b00555238ba        dpage/pgadmin4      "/entrypoint.sh"         43 minutes ago      Up 43 minutes       0.0.0.0:80->80/tcp, 443/tcp   pedantic_turing
e79fb6440a95        postgres            "docker-entrypoint.s…"   About an hour ago   Up About an hour    0.0.0.0:5432->5432/tcp        pg-docker
Run Code Online (Sandbox Code Playgroud)

我成功连接了psql命令。

psql -h localhost -U postgres -d postgres
Run Code Online (Sandbox Code Playgroud)

但是,当我在pgAdmin上使用与psql相同的参数创建服务器时,出现以下错误。

无法连接到服务器:

无法连接到服务器:连接被拒绝服务器是否在主机“ localhost”(127.0.0.1)上运行并在端口5432上接受TCP / IP连接?无法连接到服务器:地址不可用服务器是否在主机“ localhost”(:: 1)上运行并接受端口5432上的TCP / IP连接?

我成功地通过docker inspect容器上给定的IPAddress连接。

顺便说一句,我检查了postgresql.conf并断言了它,listen_addresses = '*'并且还断言了pg_hba.conf包含host all all all md5

但是我不明白,为什么我不能使用本地主机地址?为什么码头工人甚至给我一个非本地地址?

postgresql docker

4
推荐指数
4
解决办法
2707
查看次数

澄清为什么我不能通过它的子类型使用泛型类参数覆盖方法

鉴于以下情况(scastie

trait Element
class Earth extends Element

trait Container[T]
class ContainerEarth extends Container[Earth]

trait Dummy[E <: Element] {

  def dummy(container: Container[E]): Any
}

class EarthDummy extends Dummy[Earth] {

  def dummy(container: ContainerEarth): Any = ??? // could not override
  override def dummy(container: Container[Earth]): Any = ???
}
Run Code Online (Sandbox Code Playgroud)

我的脑子里仍然不清楚,为什么 ContaineEarth 不能覆盖。

我有一个解决业务问题的解决方案,但我需要了解为什么编译器拒绝替换。

trait Dummy[E <: Element, C <: Container[E]] {

  def dummy(container: C): Any
}
Run Code Online (Sandbox Code Playgroud)

我被告知游戏中存在差异,并防止它发生。

但对我来说,方差是关于Container[Dirt]Container[Earth]的子类型,如果DirtContainer通用参数是协变时扩展Earth

所以我愿意接受你的所有澄清。

oop inheritance overriding scala

3
推荐指数
1
解决办法
92
查看次数

带有布尔值的受歧视联合

问题

与布尔类型的歧视联合似乎仅适用于真正的关联类型。

复制者

interface DummyA {
  hint: true
  a: string
}

interface DummyB {
  hint: false
  b: string
}

type Dummy =
  | DummyA
  | DummyB;

const dummies: Dummy[] = [
  {
    hint: true,
    a: "a"
  },
  {
    hint: false,
    b: "b"
  }
]

dummies.forEach(value => {
  if (value.hint) {
    value.a
  } else {
    value.b
  }
})
Run Code Online (Sandbox Code Playgroud)

预期结果

如果它与 true 一起工作,它也应该与 false 一起工作。这是正常行为,还是更像是一个问题?

typescript

2
推荐指数
1
解决办法
511
查看次数

标签 统计

docker ×1

inheritance ×1

oop ×1

overriding ×1

postgresql ×1

scala ×1

typescript ×1