Bitbucket管道 - 访问另一个容器

时间:2017-04-20 13:02:44

标签: node.js docker containers bitbucket-pipelines

这是我的bitbucket-pipelines.yml配置文件:

2017-04-20 13:56:54.810 nav[8614:3232848] *** Assertion failure in -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/NSLayoutConstraint_UIKitAdditions.m:649
2017-04-20 13:56:54.927 nav[8614:3232848] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
*** First throw call stack:
(
0   CoreFoundation                      0x0000000102ab5d4b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x000000010141421e objc_exception_throw + 48
2   CoreFoundation                      0x0000000102ab9e42 +[NSException raise:format:arguments:] + 98
3   Foundation                          0x00000001038d466d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4   UIKit                               0x0000000105a4d57b __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 206
5   UIKit                               0x0000000105a4d417 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 418
6   UIKit                               0x0000000105a4d7e8 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 30
7   UIKit                               0x0000000105a4d8fa -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 221
8   UIKit                               0x0000000105a4dc0e __50-[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke + 208
9   Foundation                          0x000000010385a3b0 -[NSISEngine withBehaviors:performModifications:] + 155
10  UIKit                               0x0000000105a4db2f -[UIView(UIConstraintBasedLayout) addConstraints:] + 277
11  nav                                 0x00000001000d2ae2 __unnamed_64 + 98
12  nav                                 0x00000001004b495c vm_dispatch + 1372
13  nav                                 0x00000001004b8511 rb_scope__strain__ + 1313
14  nav                                 0x00000001009d9135 rb_vm_dispatch + 7221
15  nav                                 0x00000001004b495c vm_dispatch + 1372
16  nav                                 0x00000001004b7a3e rb_scope__initialize__ + 238
17  nav                                 0x00000001009d9135 rb_vm_dispatch + 7221
18  nav                                 0x000000010092ec57 rb_class_new_instance0 + 855
19  nav                                 0x00000001009d86e6 rb_vm_dispatch + 4582
20  nav                                 0x000000010076c1ec vm_dispatch + 1372
21  nav                                 0x0000000100780bc3 rb_scope__main_layout__ + 275
22  nav                                 0x00000001009d9135 rb_vm_dispatch + 7221
23  nav                                 0x000000010076c1ec vm_dispatch + 1372
24  nav                                 0x0000000100777955 rb_scope__layout__ + 133
25  nav                                 0x00000001009d9135 rb_vm_dispatch + 7221
26  nav                                 0x000000010076c1ec vm_dispatch + 1372
27  nav                                 0x0000000100778496 rb_scope__viewDidLoad__ + 534
28  nav                                 0x00000001007784ed __unnamed_67 + 13
29  UIKit                               0x000000010522aa3d -[UIViewController loadViewIfRequired] + 1258
30  UIKit                               0x0000000105231062 -[UIViewController __viewWillAppear:] + 118
31  UIKit                               0x000000010525c1d3 -[UINavigationController _startCustomTransition:] + 1290
32  UIKit                               0x000000010526ce48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
33  UIKit                               0x000000010526dfdb -[UINavigationController __viewWillLayoutSubviews] + 58
34  UIKit                               0x0000000105464dd7 -[UILayoutContainerView layoutSubviews] + 223
35  UIKit                               0x000000010514dab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
36  QuartzCore                          0x0000000104b4ebf8 -[CALayer layoutSublayers] + 146
37  QuartzCore                          0x0000000104b42440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
38  QuartzCore                          0x0000000104b422be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
39  QuartzCore                          0x0000000104ad0318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
40  QuartzCore                          0x0000000104afd3ff _ZN2CA11Transaction6commitEv + 475
41  QuartzCore                          0x0000000104afdd6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
42  CoreFoundation                      0x0000000102a5a267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
43  CoreFoundation                      0x0000000102a5a1d7 __CFRunLoopDoObservers + 391
44  CoreFoundation                      0x0000000102a3ef8e __CFRunLoopRun + 1198
45  CoreFoundation                      0x0000000102a3e884 CFRunLoopRunSpecific + 420
46  GraphicsServices                    0x0000000107e57a6f GSEventRunModal + 161
47  UIKit                               0x0000000105088c68 UIApplicationMain + 159
48  nav                                 0x00000001000a9fd2 main + 146
49  libdyld.dylib                       0x0000000106f1b68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我想用psql初始化数据库。 唯一的问题:我如何访问容器?

我尝试了我知道的对于docker的经典命令:

# This is a sample build configuration for Javascript.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:6.9.5

pipelines:
  default:
    - step:
        script:
          # Step 1 : Install yarn with the easy way : https://yarnpkg.com/en/docs/install#alternatives-tab
          - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.22.0
          # Step 2: Belived https://confluence.atlassian.com/bitbucket/javascript-node-js-with-bitbucket-pipelines-873891287.html#Javascript(Node.js)withBitbucketPipelines-ManagingdependencieswithYarn
          # PATH variable should change like they said
          - export PATH=$HOME/.yarn/bin:$PATH
          # Step 3: Install app dependencies
          - yarn install
          #Allow to test app in production context
          - export NODE_ENV=production
          #Allow to specify the JWT TOKEN Signature (and not use OAuth0)
          - export SECRET_SIGNATURE_JWT_TOKEN=pokémon47
          # prepare PostgreSQL
          # -  psql -U "postgres" -c "CREATE DATABASE custom_db" # create a new database
          # -  psql -U "postgres" -c "CREATE USER custom_user WITH PASSWORD 'custom_pass'" # create a new user : custom_user
          # -  psql -U "postgres" -d "custom_db" -f sql/database_tables.sql # create tables
          # -  psql -U "postgres" -d "custom_db" -f sql/database_grant.sql # give him the credentials
          # -  psql -U "postgres" -d "custom_db" -f sql/test_insert.sql # add basic data inside the database : some parkings and reasons
          #run the test with database
          - npm test
        services:
          - postgres

definitions:
  services:
    postgres:
      image: postgres:9.3

结果:

docker ps

docker exec -it myContainer bash

(我无权在此CI上启用docker守护程序)

我使用的文档:https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.htmlhttps://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html#TestwithdatabasesinBitbucketPipelines-PostgreSQL - defaultuser

PS:如果你想要Postgresql容器中的日志:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

1 个答案:

答案 0 :(得分:1)

Bitbucket文档尝试清楚,但它并不试图帮助用户:

  

PostgreSQL将在localhost上提供:5432

问题是,psql无法正常工作。它们的默认行为是连接到文件套接字(/var/run/postgresql/.s.PGSQL.5432),而不是localhost

您必须将host参数设置为connect:psql -h localhost