在docker中运行,连接postgres数据库报错 sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused 5C

postgres服务已经连接

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:80 chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 80:80 chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:5432 chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker build -t chiral:v1 .
Sending build context to Docker daemon  20.96MB
Step 1/13 : FROM mcs07/rdkit:latest
 ---> 03f8370e36cf
Step 2/13 : RUN echo deb http://mirrors.aliyun.com/debian stretch main contrib non-free > /etc/apt/sources.list;     echo deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free >> /etc/apt/sources.list;     echo deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free >> /etc/apt/sources.list;     echo deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free >> /etc/apt/sources.list;     echo deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib >> /etc/apt/sources.list;     echo deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib >> /etc/apt/sources.list     && apt-get update     && apt-get install python3-pip --assume-yes     && pip3 install setuptools-scm && pip3 install --upgrade setuptools    && pip3 install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/ xlrd Pillow setuptools sklearn flask numpy pandas psycopg2-binary wtforms==2.2.1 flask-wtf==0.14.2 flask-sqlalchemy==2.4.1 werkzeug==0.16.1     && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
 ---> Using cache
 ---> cf3090a98808
Step 3/13 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 87d4100cc593
Step 4/13 : COPY . .
 ---> 72064b4ad609
Step 5/13 : ENV LISTEN_PORT 5432
 ---> Running in c1431f25230d
Removing intermediate container c1431f25230d
 ---> c1bf69d49133
Step 6/13 : EXPOSE 5432
 ---> Running in e23534149810
Removing intermediate container e23534149810
 ---> 514d5bad82a2
Step 7/13 : ENV DATASOURCE_DBNAME=chiral
 ---> Running in ff2405f0865c
Removing intermediate container ff2405f0865c
 ---> d4c1c91e74d8
Step 8/13 : ENV DATASOURCE_USER=postgres
 ---> Running in 9fa8cdbecb95
Removing intermediate container 9fa8cdbecb95
 ---> fb5930e31c98
Step 9/13 : ENV DATASOURCE_PASSWORD=wuxiapptec
 ---> Running in 99f2369a4e1c
Removing intermediate container 99f2369a4e1c
 ---> e9e2566db00b
Step 10/13 : ENV DATASOURCE_HOST=localhost
 ---> Running in ff8e2789fe9f
Removing intermediate container ff8e2789fe9f
 ---> 9697ede791e5
Step 11/13 : ENV DATASOURCE_PORT=5432
 ---> Running in fec654683ab2
Removing intermediate container fec654683ab2
 ---> 8e8066352df3
Step 12/13 : ENV WEB_PATH=
 ---> Running in c545308e00fa
Removing intermediate container c545308e00fa
 ---> a97b043d6d40
Step 13/13 : CMD ["python3", "./app.py"]
 ---> Running in 8f72fd9e39d3
Removing intermediate container 8f72fd9e39d3
 ---> dbd5fa324af0
Successfully built dbd5fa324af0
Successfully tagged chiral:v1
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:5432 chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

(Background on this error at: http://sqlalche.me/e/e3q8)
PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 80:80 chiral:v1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./app.py", line 9, in <module>
    from database import Sample, Recommend, User, app, db
  File "/usr/src/app/database.py", line 117, in <module>
    db.drop_all()
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all
    self._execute_for_all_tables(app, bind, 'drop_all')
  File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all
    ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
    with self._contextual_connect() as conn:
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
    exc_value, with_traceback=exc_tb,
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

2个回答

postgresql的服务有没有打开
端口、地址、ip
docker是否允许访问网络,以及防火墙
https://blog.csdn.net/switch513/article/details/77366247

连接被主动拒绝,说明服务器应该是开着的,不然也不会主动拒绝
被拒绝的原因可能是你对外的端口没有开启,而你又恰好用到了,所以我初步判断解决办法,应该把postgresql的端口策略开一下,
当然如果有网关,网关策略也需要检查

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
docker 挂载容器时报错

``` PS C:\WINDOWS\system32> docker run -d -p 80:80 --name lnmp -v E:/jbp07/jbp- C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response fro dy in use by container a271d8ef0a67170bfd943089af1299434e71cb645287216e393c that container to be able to reuse that name.. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'. ```

Docker容器如何跨主机连接数据库

## 问题描述: 例如:我要创建一个 sonar 容器,如何使 sonar 连接到不同主机上的数据库。 ## 简单介绍: 下面的代码是目前我在一台主机上运行MySQL和Sonar,如何修改Sonar的启动代码,达到让Sonar和MySQL分布在不同的主机呢? ### 主机A 启动 MySQL docker run \ -d \ -p 3307:3306 \ --name mysql \ -v /data/mysql/conf:/etc/mysql/conf.d \ -v /data/mysql/logs:/logs \ -v /data/mysql/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ mysql:5.7 ### 主机A 启动 Sonar docker run \ -d \ --name sonarqube \ -p 9000:9000 \ -p 9092:9092 \ --link=mysql:mysql \ -v /data/sonarqube/logs:/opt/sonarqube/logs \ -v /data/sonarqube/conf:/opt/sonarqube/conf \ -v /data/sonarqube/data:/opt/sonarqube/data \ -v /data/sonarqube/extensions:/opt/sonarqube/extensions \ -e SONARQUBE_JDBC_USERNAME=sonar \ -e SONARQUBE_JDBC_PASSWORD=sonar \ -e SONARQUBE_JDBC_URL="jdbc:mysql://10.9.40.121:3307/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false" \ sonarqube:7.4-community

Docker 中java程序对外请求,报错:Root Cause exception : java.net.UnknownHostException

1、在虚拟机中centos7 系统中,安装了Docker环境,想实现在docker中运行 “java -jar test.jar”,其中test.jar的main函数中会对外发起http请求,url=“http://plm.xxx.com:9091/xxx”,初始启动运行镜像文件就报错: ``` java.net.UnknownHostException: PLM at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901 ``` 2、我配置的dockfile 文件为: ``` From centos MAINTAINER liubin ADD test.jar test.jar ADD jdk-7u80-linux-x64.tar.gz /home/jdk/ ENV JAVA_HOME /home/jdk/jdk1.7.0_80 ENV PATH $JAVA_HOME/bin:$PATH ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENTRYPOINT ["java","-jar","test.jar"] ``` 3、直接尝试在centos环境中运行java -jar test.jar不会报异常,我的/etc/hosts文件中配置了PLM相关地址 ``` 127.0.0.1 node1 localhost ::1 node1 localhost 192.168.2.18 plm.xxx.com plmapp PLM #与请求地址相关的域名 192.168.2.113 ode1 192.168.2.128 AAASPLMIFS ``` 4、我的问题是docker 中运行java程序报这个UnknownHostException,是不是需要在Dockerfile中配置其它内容。 不好意思,最近没有积分呀、

使用docker 制作python 镜像是报错

Dockerfile 如下 FROM python:2.7 LABEL maintainer="xiaodao11 295621649@qq.com" RUN pip install flask COPY app.py /app/ WORKDIR /app EXPOSE 5000 CMD ["python","app.py"] docker build ....报错 .. Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x7f759b4c4610>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/selectivesearch/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._ve............. 环境是阿里云 服务器 centos 7

Docker安装Hue,启动Hue报错,报错内容见截图,望高人指点

Docker安装Hue,启动Hue报错,报错内容见截图,望高人指点 启动操作 1、从Docker Hub获取镜像 sudo docker pull gethue/hue:latest 2、运行镜像 docker run -it -p 8888:8888 gethue/hue:latest bash 3、容器内启动HUE ./build/env/bin/supervisor ![图片说明](https://img-ask.csdn.net/upload/201907/12/1562940031_423619.jpg)

docker中的数据库连接超时

<div class="post-text" itemprop="text"> <p><strong>Environment</strong></p> <ul> <li>Environment: Mac and Docker </li> <li>Language: GoLang </li> <li>Database: Postgresql</li> </ul> <p><strong>Expected Behavior</strong></p> <p>We have a connection pool used to connect to database. The time of database connection may vary from 1 minute up to 20 minutes depending on the functions being called.</p> <p><strong>Actual Behavior</strong></p> <ul> <li>Running in local: everything is fine.</li> <li><p>Running in Docker: DB connection that is less than 5 minutes is fine. For DB connection that is longer than 5 minutes, every 5-6 minutes the connection is broken in docker and a new connection is initiated automatically. After 3 reconnections, following error is returned and process is terminated</p> <p>driver: bad connection</p></li> </ul> <p><strong>Some Tries</strong></p> <ul> <li>try to ping database during the function call to keep connection alive -- not works (working in some simple cases, but not in complicate case and not stable.</li> <li>try to ping database during function call with same connection using db.SetMaxOpenConns(1) and db.SetMaxIdleConns(1) -- not works.</li> <li>try to set connection life to longer with db.SetConnMaxLifetime() -- not works.</li> </ul> <p><strong>Some Info</strong></p> <p>After some search, the possible reason is that docker periodically checks connections and time them out if connection is alive for 300 seconds and no response returns. Not find any way to overwrite this configuration.</p> <p><a href="https://github.com/moby/moby/issues/36053" rel="nofollow noreferrer">https://github.com/moby/moby/issues/36053</a></p> <p><a href="https://github.com/docker/for-mac/issues/2442" rel="nofollow noreferrer">https://github.com/docker/for-mac/issues/2442</a></p> <p><strong>How can I get around this issue? Appreciate if any help.</strong></p> </div>

扩展docker postgres映像以创建额外的数据库

<div class="post-text" itemprop="text"> <p>I've already seen this topic : <a href="https://stackoverflow.com/a/26599273/2323245">https://stackoverflow.com/a/26599273/2323245</a></p> <p>But I have the following problem :</p> <pre><code>postgres_1 | FATAL: role "docker" does not exist app_1 | Error: Could not establish a connection with the database </code></pre> <p>This is my docker-compose.yml file</p> <pre><code>version: "2" services: app: build: context: . dockerfile: Dockerfiles/app.dockerfile links: - postgres depends_on: - postgres ports: - "8080:8080" environment: PORT: 8080 networks: - neo_dev restart: always postgres: build: context: . dockerfile: Dockerfiles/postgres.dockerfile networks: - neo_dev volumes: - postgresql:/var/lib/postgresql # This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52 - postgresql_data:/var/lib/postgresql/data ports: - "5430:5432" #in case you already have postgres running in your host machine networks: neo_dev: driver: bridge volumes: postgresql: postgresql_data: </code></pre> <p>My postgres.dockerfile is </p> <pre><code>FROM library/postgres MAINTAINER Samir Bouaked "sbouaked@neocasesoftware.com" ADD Dockerfiles/init.sql /docker-entrypoint-initdb.d/ </code></pre> <p>And this is my init.sql file</p> <pre><code>CREATE USER docker with password 'docker'; CREATE DATABASE docker; GRANT ALL PRIVILEGES ON DATABASE docker TO docker; </code></pre> <p>In my golang app, i'm trying to reach the database with</p> <pre><code>router.GET("/db", func(c *gin.Context) { db, err := sql.Open("postgres", "host=postgres port=5432 user=docker dbname=docker password=docker sslmode=disable") if err != nil { log.Fatal("Error: The data source arguments are not valid - " + err.Error()) } err = db.Ping() if err != nil { log.Println("Error: Could not establish a connection with the database") c.String(http.StatusOK, "hotstName : %s DbStatus : %s", os.Getenv("HOSTNAME"), err) } else { c.String(http.StatusOK, " hotstName : %s DbStatus : connection ok ! ", os.Getenv("HOSTNAME")) } defer db.Close() }) </code></pre> <p>I tried different solutions like passing directly in the dockerfile env variables like that</p> <pre><code>ENV POSTGRES_USER docker ENV POSTGRES_PASSWORD docker ENV POSTGRES_DB docker </code></pre> <p>But have always the same result... For more information you can check this repo <a href="https://github.com/neocase/docker-go-starter-kit" rel="nofollow noreferrer">https://github.com/neocase/docker-go-starter-kit</a></p> <p>I don't understand the problem</p> </div>

Docker 运行问题,输入docker命令报错

我用win 10 自带的hyper-v 虚拟机运行docker 在cmd窗口输入docker命令报错。 如果不running docker 如图1 如果running docker 如图2 求大神指导哈 万分感谢![图片说明](https://img-ask.csdn.net/upload/201704/26/1493209685_665183.png)![图片说明](https://img-ask.csdn.net/upload/201704/26/1493209698_848564.png)

从容器连接到远程数据库服务器时出错

<div class="post-text" itemprop="text"> <p>I have a service deployed in mesos, which queries a remote database server. I used <a href="http://github.com/go-sql-driver/mysql" rel="nofollow noreferrer"><code>github.com/go-sql-driver/mysql</code></a> to query the database from my Go code. It was working fine for about a week. But today I got this error: <code>driver: bad connection</code></p> <p>So I entered the docker container where my service runs and type in command line: </p> <pre><code>mysql -uxxx -hx.x.x.x -Pxxx -Dxxx -pxxx </code></pre> <p>Here's the response: </p> <pre><code>ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 </code></pre> <p>This is the content of /etc/mysql/my.cnf file:</p> <pre><code>[mysql] no-auto-rehash # Faster start of mysql but no tab completition </code></pre> <p>What can be the error here? And how can I solve this?</p> <p>Edit: When I run the same command from my local machine it works fine. I can query the database from the command line of my pc.</p> </div>

编译webservice报错.......

mssoap30.tli “return”: 无法从“__missing_type__ *”转换为“__missing_type_

如何在Docker容器之间建立连接

<div class="post-text" itemprop="text"> <p>I am having connection issues when I try to connect my goLang GORM service to a Docker Postgress container. I believe the problem is my golang code at the bottom at the connection string.</p> <pre><code>docker-compose up Recreating postgress_postgre_1 ... done Attaching to postgres postgres | 2018-12-11 21:08:48.283 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres | 2018-12-11 21:08:48.283 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres | 2018-12-11 21:08:48.291 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres | 2018-12-11 21:08:48.316 UTC [20] LOG: database system was shut down at 2018-12-11 21:08:44 UTC postgres | 2018-12-11 21:08:48.328 UTC [1] LOG: database system is ready to accept connections </code></pre> <p>=== when I run the golang I get... panic: failed to connect database</p> <p>=============== docker-compose.yml</p> <pre><code>version: '3.6' services: postgre: image: postgres:11.1-alpine ports: - '5432:5432' network_mode: bridge container_name: postgres environment: POSTGRES_USER: 'user' POSTGRES_PASSWORD: 'password' POSTGRESS_DB: 'db_amex01' volumes: - ./init:/docker-entrypoint-initdb.d/ </code></pre> <p>==== main.go</p> <p>package main</p> <pre><code>import ( "fmt" "log" "net/http" "github.com/gorilla/mux" "github.com/jinzhu/gorm" // _ "github.com/jinzhu/gorm/dialects/sqlite" _ "github.com/jinzhu/gorm/dialects/postgres" ) // _ "github.com/jinzhu/gorm/blob/master/dialects/postgres" type ToDo struct { gorm.Model ID int `json:"id"` TASK_STRING string `json:"task_string"` DONE bool `json:"done"` } var db *gorm.DB var err error func main() { const ( host = "localhost" port = 5432 user = "postgres" password = "password" dbname = "db_amex01" ) // this is the problem I believe I am having... db, err := gorm.Open("postgres", "host='postgres' port=5432 user=user dbname='db_amex01' password='password'") defer db.Close() if err != nil { panic("failed to connect database") } defer db.Close() </code></pre> </div>

Postgres错误在数据库上运行查询:无法检测默认用户名

<div class="post-text" itemprop="text"> <p>Hi I am trying to monitor postgres SQL with Prometheus. For this purpose I am using this exporter <a href="https://github.com/wrouesnel/postgres_exporter" rel="nofollow">https://github.com/wrouesnel/postgres_exporter</a></p> <p>I am starting the exporter in my <code>docker-compose.yml</code> like this:</p> <pre><code> exporter-postgres: image: wrouesnel/postgres_exporter ports: - 9113:9113 environment: - DATA_SOURCE_NAME="postgresql://user:pass@localhost:5432/?sslmode=disable" </code></pre> <p>When the exporter is trying to access the database errors like this are thrown:</p> <pre><code>Error running query on database: pg_stat_database pg: Could not detect default username. Please provide one explicitly. file="postgres-exporter.go" line=490 </code></pre> <p>and </p> <pre><code>Error scanning runtime variable: pg_stat_database pg: Could not detect default username. Please provide one explicitly. file="postgres-exporter.go" line=464 </code></pre> <p>I am not really sure what this message could mean. Also I am not really sure if the issues originates in my docker-compose file, or the exporter.</p> <p>The lines which throw the error in the <code>postgres-exporter.go</code> are:</p> <pre><code>// Use SHOW to get the value row := db.QueryRow(fmt.Sprintf("SHOW %s;", columnName)) var val interface{} err := row.Scan(&amp;val) if err != nil { log.Errorln("Error scanning runtime variable:", columnName, err) continue } </code></pre> <p>and</p> <pre><code>query, er := queryOverrides[namespace] if er == false { query = fmt.Sprintf("SELECT * FROM %s;", namespace) } // Don't fail on a bad scrape of one metric rows, err := db.Query(query) if err != nil { log.Println("Error running query on database: ", namespace, err) e.error.Set(1) return } </code></pre> <p><a href="https://github.com/wrouesnel/postgres_exporter/blob/master/postgres_exporter.go" rel="nofollow">https://github.com/wrouesnel/postgres_exporter/blob/master/postgres_exporter.go</a></p> <p>I am thankful for any help!</p> <p>Edit:</p> <p>Here is the connection to the database:</p> <pre><code>db, err := sql.Open("postgres", e.dsn) </code></pre> <p>Whereas <code>e.dsn</code> is generated like this:</p> <pre><code>dsn := os.Getenv("DATA_SOURCE_NAME") </code></pre> <p>The connection doesn't throw any error</p> </div>

如何使用docker-compose连接到PostgreSQL?

<div class="post-text" itemprop="text"> <p>Want to use <code>docker-compose</code> to run api application and postgresql database together. </p> <p><code>docker-compose</code> file:</p> <pre><code>version: '3' volumes: database_data: driver: local services: db: image: postgres:latest volumes: - database_data:/var/lib/postgresql/data api: build: ./api expose: - 8080 ports: - 8080:8080 volumes: - ./api:/usr/src/app/ links: - db environment: - PGHOST=db - PGDATABASE=postgres - PGUSER=postgres </code></pre> <p>Api <code>main.go</code> file:</p> <pre><code>func main() { db, err = gorm.Open("postgres", "host=db port=5432 user=postgres dbname=postgres") // ... } </code></pre> <p>When run the services, got message from log:</p> <pre><code>api_1 | [GIN] 2018/06/22 - 07:31:10 | 404 | 1.4404ms | 172.20.0.1 | GET /posts api_1 | api_1 | (sql: database is closed) api_1 | [2018-06-22 07:31:10] api_1 | api_1 | (sql: database is closed) api_1 | [2018-06-22 07:31:10] api_1 | [GIN] 2018/06/22 - 07:32:14 | 403 | 15.6µs | 172.20.0.1 | GET /posts db_1 | 2018-06-22 07:34:27.296 UTC [81] FATAL: role "root" does not exist db_1 | 2018-06-22 07:34:36.897 UTC [90] FATAL: role "root" does not exist </code></pre> <p>Does this way not good? <code>host=db</code> in the connection string? Since <code>db</code> is the docker compose service name.</p> <hr> <h1>Add</h1> <p>It can work:</p> <p><a href="https://docs.docker.com/samples/library/postgres/#-or-via-psql" rel="nofollow noreferrer">https://docs.docker.com/samples/library/postgres/#-or-via-psql</a></p> </div>

本地的pgAdmin可以连postgresql的docker镜像吗?

我从github上clone了一个project,然后readme上说要运行docker-compose up来运行 postgresql镜像,我看了下配置文件端口映射到5432,也就是说当我运行后,5432被postgresql server的docker镜像占用。我npm start启动项目后,项目的ORM框架自动生产数据库表,然后我本地有pgadmin,然后我启动pgadmin的时候告诉我连接成功,但是找不到ORM生成的表,请问我本地的pgadmin既然连接到port5432的server,为什么不显示这些表呢?

Redis在Docker容器中失去连接

<div class="post-text" itemprop="text"> <p>I am making a PubSub using redigo and the connection is created by redis pool.</p> <p>This is the Redis Pool code:</p> <pre><code>package main import ( "os" "os/signal" "syscall" "time" "github.com/gomodule/redigo/redis" ) type IRedis interface { Addr() string Conn() redis.Conn Set(key string, body string) error Close() } type Redis struct { addr string pool *redis.Pool } func NewRedis(addr string) *Redis { r := &amp;Redis{ addr, &amp;redis.Pool{ MaxIdle: 50000, IdleTimeout: 240 * time.Second, Dial: func() (redis.Conn, error) { c, err := redis.Dial("tcp", addr) if err != nil { return nil, err } return c, err }, TestOnBorrow: func(c redis.Conn, t time.Time) error { _, err := c.Do("PING") return err }, }, } r.cleanupHook() return r } func (r *Redis) cleanupHook() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) signal.Notify(c, syscall.SIGTERM) signal.Notify(c, syscall.SIGKILL) go func() { &lt;-c r.pool.Close() os.Exit(0) }() } func (r *Redis) Addr() string { return r.addr } func (r *Redis) Conn() redis.Conn { return r.pool.Get() } func (r *Redis) Set(key string, body string) error { p := r.pool.Get() defer p.Close() _, err := p.Do("SET", key, body) return err } func (r *Redis) Close() { r.pool.Close() } </code></pre> <p>This is my PubSub code:</p> <pre><code>package main import ( "log" "github.com/gomodule/redigo/redis" ) type PubSub struct { send chan string conn *redis.PubSubConn } func NewPubSub(s chan string, c *redis.PubSubConn) (*PubSub, error) { err := c.Subscribe("urls") if err != nil { return nil, err } return &amp;PubSub{s, c}, nil } func (ps *PubSub) Start() { for { switch v := ps.conn.Receive().(type) { case redis.Message: data := string(v.Data) ps.send &lt;- data case redis.Subscription: log.Printf("subscription message: %s: %s %d ", v.Channel, v.Kind, v.Count) case error: log.Println("error:", v) return } } } func (ps *PubSub) Close() { ps.conn.Close() } </code></pre> <p>and after I receive 10k messages in my PubSub channel the connection is lost and I receive an redis.Error with the message EOF</p> <p>Any thoughts why this is happen? Even when I run locally the problem happens</p> </div>

无法在运行wordpress docker中连接mysql

<div class="post-text" itemprop="text"> <p>I used the script to start mysql and wordpress through docker. (<a href="https://github.com/lamuguo/wordpress-setup/blob/master/start_wordpress.sh" rel="nofollow">https://github.com/lamuguo/wordpress-setup/blob/master/start_wordpress.sh</a>)</p> <p>The xfguo-wp image is built based on docker official wordpress 4.3.1 repository: <a href="https://github.com/docker-library/wordpress/commit/4823a04099579f2aafb118ae8177449425cc84d2" rel="nofollow">https://github.com/docker-library/wordpress/commit/4823a04099579f2aafb118ae8177449425cc84d2</a></p> <p>Command to build the image: (under apache directory) ~/github/wordpress/apache$ docker build -t xfguo-wp . </p> <p>However, I can't connect to mysql DB successfully, error below by "docker logs techmeetup-wordpress"</p> <p>... WordPress not found in /var/www/html - copying now... Complete! WordPress has been successfully copied to /var/www/html</p> <p>MySQL Connection Error: (2002) Connection refused</p> <p>Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 10</p> <p>Any thoughts? Feel free to comment in the code of my wordpress-setup repository.</p> <p>Thanks!</p> </div>

win7 docker 2375端口连接拒绝

springcloud 项目 在install 的时候会连接docker,但是会报以下错误: Caused by: com.spotify.docker.client.shaded.org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect, dockerfile-maven-plugin版本是1.4.9。

docker容器重启后报错

日志如下 ``` Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/7.0.67 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Dec 7 2015 13:07:11 UTC Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 7.0.67.0 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Linux Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 3.10.0-327.el7.x86_64 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: /opt/heading/jdk1.6.0_45/jre Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.6.0_45-b06 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Sun Microsystems Inc. Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: /opt/heading/pfs Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: /opt/heading/pfs Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.util.logging.config.file=/opt/heading/pfs/conf/logging.properties Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Duser.timezone=GMT+08 Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Xms512m Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Xmx1024m Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -XX:PermSize=256M Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -XX:MaxPermSize=512M Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=/opt/heading/pfs/endorsed Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=/opt/heading/pfs Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=/opt/heading/pfs Oct 26, 2016 5:05:47 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.io.tmpdir=/opt/heading/pfs/temp Oct 26, 2016 5:05:47 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /opt/heading/jdk1.6.0_45/jre/lib/amd64/server:/opt/heading/jdk1.6.0_45/jre/lib/amd64:/opt/heading/jdk1.6.0_45/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Oct 26, 2016 5:05:48 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Oct 26, 2016 5:05:48 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Oct 26, 2016 5:05:48 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 4462 ms Oct 26, 2016 5:05:48 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-10001"] Oct 26, 2016 5:05:48 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-10009"] Oct 26, 2016 5:05:48 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 4458 ms Oct 26, 2016 5:05:48 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Oct 26, 2016 5:05:48 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.67 Oct 26, 2016 5:05:48 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /opt/heading/dts/webapps/ROOT Oct 26, 2016 5:05:48 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Oct 26, 2016 5:05:48 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.67 Oct 26, 2016 5:05:48 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /opt/heading/pfs/webapps/ROOT Oct 26, 2016 5:05:52 PM org.apache.tomcat.websocket.server.WsSci onStartup INFO: JSR 356 WebSocket (Java WebSocket 1.1) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. Oct 26, 2016 5:05:52 PM org.apache.tomcat.websocket.server.WsSci onStartup INFO: JSR 356 WebSocket (Java WebSocket 1.1) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. ``` 求大神帮分析下原因

无法连接到Docker容器内的postgresql

<div class="post-text" itemprop="text"> <p>I'm writing a go app which is dockerized in 2 containers: db and app.</p> <p>while starting containers 'docker-compose up' I see the message: <em>dial tcp: lookup dbpgsql on 127.0.0.11:53: no such host</em></p> <pre><code>DB_ENV_DB=cldb DB_ENV_USER=cldb DB_ENV_PASS=cldb DB_PORT_5432_TCP_ADDR=dbpgsql DB_PORT_5432_TCP_PORT=5432 </code></pre> <p>here is my docker-compose.yml</p> <pre><code>version: '2' services: server: hostname: app image: golang:1.7.3-alpine build: ./server/ privileged: true container_name: server command: go run server.go volumes: - ../src/:/go/src/ - ../server.go:/go/server.go links: - db:db ports: - '8080:8080' env_file: environment db: hostname: dbpgsql image: postgres:latest container_name: db environment: POSTGRES_USER: cldb POSTGRES_PASSWORD: cldb POSTGRES_DB: cldb ports: - '5432:5432' volumes: - ./data:/docker-entrypoint-initdb.d </code></pre> <p>The app fails here when DB.Ping() is executed:</p> <pre><code>func InitDB(dataSourceName string) { var err error DB, err = sql.Open("postgres", dataSourceName) if err != nil { log.Panic(err) } if err = DB.Ping(); err != nil { log.Panic(err) } DB.SetMaxIdleConns(100) } </code></pre> </div>

如果能重来,我不会选择北漂——初见北京

一个人走的路

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

2020年大厂Java面试前复习的正确姿势(800+面试题答案解析)

前言 个人觉得面试也像是一场全新的征程,失败和胜利都是平常之事。所以,劝各位不要因为面试失败而灰心、 丧失斗志。也不要因为面试通过而沾沾自喜,等待你的将是更美好的未来,继续加油! 本篇分享的面试题内容包括:Java、MyBatis、ZooKeeper、Dubbo、Elasticsearch、Redis、MySQL、Spring、SpringBoot、SpringCloud、RabbitMQ...

抖音上很火的时钟效果

反正,我的抖音没人看,别人都有几十万个赞什么的。 发到CSDN上来,大家交流下~ 主要用到原生态的 JS+CSS3。 具体不解释了,看注释: &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Title&lt;/tit...

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

又出事了?网站被攻击了?高中生?

北京时间2020年3月27日9点整,如往常一样来到公司,带开电脑,正准备打开Github网站看一会源代码,再开始手头的工作。哟吼,一直打不开,一直出现如下页面: 我想很多网友也尝到了甜头,各大技术群炸开了锅,据网友反馈有攻击者正在发起大规模的中间人挟持,京东和Github等网站等网站都受到了影响。 什么是中间中间人挟持呢? 简而言之,就是攻击者在数据网络传输的过程中,截获传输过程中的数据并篡改...

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

我把华为小米年报放一起,发现华为才是真·手机公司,小米确实不靠卖手机赚钱...

郭一璞 发自 凹非寺量子位 报道 | 公众号 QbitAI国产手机界的两大玩家,华为&amp;小米,昨天在同一天前后脚发布了2019年财报。同行冤家,发财报也碰在了同一天。那我们就对比...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

十个摸鱼,哦,不对,是炫酷(可以玩一整天)的网站!!!

文章目录前言正文**1、Kaspersky Cyberthreat real-time map****2、Finding Home****3、Silk – Interactive Generative Art****4、Liquid Particles 3D****5、WINDOWS93****6、Staggering Beauty****7、Ostagram图片生成器网址****8、全历史网址*...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

毕业5年,我熬夜整理出了这50个优质的电子书网站,吐血推荐!

大家好,我是武哥,最近经常有小伙伴问我要电子书,都什么年代了,还找不到电子书吗?如果要说原因,那就是你还没遇到武哥我(手动滑稽~)!我今天把这么多年我经常看的电子书网站整理一下给大家,基本上能解决大家的需求。不管是在校生还是已经工作了,相信肯定对你有所帮助! 1.鸠摩搜书 首先给大家推荐的网站是:鸠摩搜书 地址:https://www.jiumodiary.com/ 这个网上非常棒,上面有很多优质...

MySQL性能优化(五):为什么查询速度这么慢

前期回顾: MySQL性能优化(一):MySQL架构与核心问题 MySQL性能优化(二):选择优化的数据类型 MySQL性能优化(三):深入理解索引的这点事 MySQL性能优化(四):如何高效正确的使用索引 前面章节我们介绍了如何选择优化的数据类型、如何高效的使用索引,这些对于高性能的MySQL来说是必不可少的。但这些还完全不够,还需要合理的设计查询。如果查询写的很糟糕,即使表结构再合理、索引再...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

总结了Mybatis,原来知识点也没多少嘛

看完这篇Mybatis,感觉你三天就会用了。

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

疫情后北上广深租房价格跌了吗? | Alfred数据室

去年3月份我们发布了《北上广深租房图鉴》(点击阅读),细数了北上广深租房的各种因素对租房价格的影响。一年过去了,在面临新冠疫情的后续影响、城市尚未完全恢复正常运转、学校还没开学等情况下...

面试官给我挖坑:a[i][j] 和 a[j][i] 有什么区别?

点击上方“朱小厮的博客”,选择“设为星标”后台回复&#34;1024&#34;领取公众号专属资料本文以一个简单的程序开头——数组赋值:int LEN = 10000; int[][] ...

在拼多多上班,是一种什么样的体验?我心态崩了呀!

之前有很多读者咨询我:武哥,在拼多多上班是一种什么样的体验?由于一直很忙,没抽出时间来和大家分享。上周末特地花点时间来写了一篇文章,跟大家分享一下拼多多的日常。 1. 倒时差的作息 可能很多小伙伴都听说了,拼多多加班很严重。这怎么说呢?作息上确实和其他公司有点区别,大家知道 996,那么自然也就能理解拼多多的“11 11 6”了。 所以当很多小伙伴早上出门时,他们是这样的: 我们是这样的: 当...

相关热词 c# cad插入影像 c#设计思想 c#正则表达式 转换 c#form复制 c#写web c# 柱形图 c# wcf 服务库 c#应用程序管理器 c#数组如何赋值给数组 c#序列化应用目的博客园
立即提问