Running docker with pgadmin on mac getting Error: Unable to initialize GTK+, is DISPLAY set properly?

Running docker with pgadmin on mac getting Error: Unable to initialize GTK+, is DISPLAY set properly?

我正在尝试从我的 mac (Sierra 10.12.4) 中 运行 pgadmin,如所述 here

docker run --rm --name pgadmin --link postgres:postgres -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY mdouchement/pgadmin3:1.20.0

但我收到此错误:

Error: Unable to initialize GTK+, is DISPLAY set properly?

我怎样才能 运行 docker pgadmin?

容器没有 windows 管理器,因此如果您想 运行 GUI 应用程序,您需要(例如)XQuartz / X11 在您的 Mac 上并附加容器对此。这有点棘手,可能有效,也可能无效。可以在 Docker 问题跟踪器中找到有关提示的更长时间讨论,以使其正常工作; https://github.com/docker/docker/issues/8710

但是,pgAdmin 4 可以选择通过网络服务器 运行,这使得它更适合 运行 在容器中运行。我创建了一个(非常 simple/minimal)的 pgAdmin 图像,可以在 Docker 上 运行; https://hub.docker.com/r/thajeztah/pgadmin4/,并允许您通过发布端口 5050 访问 pgAdmin(注意 默认配置没有启用访问控制/密码保护,因此请确保您没有发布可公开访问的主机上的端口)