简体   繁体   English

如何使用带有 pgadmin4 客户端的 Docker Toolbox 连接到 postgresql 实例

[英]How to connect to postgresql instance in with Docker Toolbox with pgadmin4 client

i'm new to Docker, and i'm running it with Docker Toolbox cause i have win 10 family.我是 Docker 的新手,我正在使用 Docker Toolbox 运行它,因为我赢得了 10 个家庭。 I have a training project where there is a database to put up with docker-compose.我有一个培训项目,其中有一个数据库可以使用 docker-compose。 Here is the docker-compose.yml (it's given to me, but i can modify it).这是 docker-compose.yml(它是给我的,但我可以修改它)。

 version: '2'
services:
  myerp.db:
    image: postgres:9.4
    ports:
      - "127.0.0.1:9032:5432"
    volumes:
#      - "./data/db:/var/lib/postgresql/data"
       - "./init/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
    environment:
      - POSTGRES_DB=db_myerp
      - POSTGRES_USER=usr_myerp
      - POSTGRES_PASSWORD=myerp

When i run that through Docker with docker-compose up it seems ok, but i'm unable to connect to it through a server in pgadmin4 I'm not sure of the connexion setup i'm suppose to put because of Docker ToolBox, where in general to access the running instance you don't use 127.0.0.1 but 192.168.99.100 by defaut.当我使用 docker-compose up 通过 Docker 运行它时,它似乎没问题,但我无法通过 pgadmin4 中的服务器连接到它我不确定我应该放置的连接设置,因为 Docker ToolBox,在哪里通常,要访问正在运行的实例,您不使用 127.0.0.1,而是默认使用 192.168.99.100。 Anyway, if i configure a postgresql server with Hostname: 127.0.0.1 Port: 9032 Username and password as written up, i have无论如何,如果我使用主机名配置 postgresql 服务器:127.0.0.1 端口:9032 用户名和密码如上所写,我有

could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 9032?

If i change the IP in docker-compose for 192.168.99.100, i manage to connect, but the database is not initialized although there are sql files in the folder如果我在 docker-compose 中将 IP 更改为 192.168.99.100,我设法连接,但是数据库没有初始化,尽管文件夹中有 sql 文件

\init\db\docker-entrypoint-initdb.d :
01_create_schema.sql
02_create_tables.sql
21_insert__data_demo.sql

So is it my connexion that is wrongly setup?那么是我的连接设置错误了吗? Or should i do it with 192.168.99.100, and it's the initialisation setup that is wrong in the docker-compose?或者我应该用 192.168.99.100 来做,这是 docker-compose 中错误的初始化设置?

Thanks for help !感谢帮助 !

Ok so i solve the problem, but unfortunately without Docker Toolbox.好的,我解决了这个问题,但不幸的是没有 Docker 工具箱。 I bought a key for windows 10 pro (6€), upgraded the system really fast, and installed Docker Desktop.我买了一个 windows 10 专业版密钥(6 欧元),非常快速地升级了系统,并安装了 Docker Desktop。 Everything worked instantly.一切立即奏效。 Before the connexion ip was indeed 192.168.99.100, but i don't know why the sql scripts where not copied in the virtual environment, and the folder之前connexion ip确实是192.168.99.100,但是不知道为什么虚拟环境里面的sql脚本没有复制过来,文件夹

/docker-entrypoint-initdb.d

remained empty.仍然是空的。 So my solution was to upgrade the system, and everything is fine !所以我的解决方案是升级系统,一切都很好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM