RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1132672
Accepted
don Rumata
don Rumata
Asked:2020-05-28 16:08:21 +0000 UTC2020-05-28 16:08:21 +0000 UTC 2020-05-28 16:08:21 +0000 UTC

如何在 CircleCI 中从一个容器到达另一个容器?

  • 772

有这样的东西CircleCI。码头给出了一次启动两个容器的示例:

  rake_test:
    docker:
      - image: circleci/ruby:2.4-node-jessie
      - image: circleci/postgres:9.4.12-alpine
    steps:
...
      - run: bundle --path vendor/bundle

虚拟机ruby怎么知道附近有pg,需要敲门呢?一位同事抛出了Docker Compose手册页的链接,但我也不了解那里的网络交互机制。

PS 我只读过关于 docker 的知识,并且一般都知道。没有在生产中工作。

PPS我看到了这个答案,但仍然不清楚如何在我的特定情况下应用它。

linux
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    don Rumata
    2020-05-31T06:07:46Z2020-05-31T06:07:46Z

    一切都很简单,表面上。事实证明,CircleCI有一个主容器,所有bash\python\php\js\etc脚本都在其中执行,还有其他容器可以通过网络以localhost:port 主容器的形式使用。一切都写在这里。

    例如,我决定尝试一堆ubuntu 18.04and nginx。

    .circleci/config.yml:

    ---
    version: 2.1
    
    executors:
    
      test-bridge:
        resource_class: small
        docker:
          - image: ubuntu:18.04
          - image: nginx:latest
    
    jobs:
    
      run-test-bridge:
        executor: test-bridge
        steps:
          - checkout
          - run:
              name: Run 2 containers 4 test local network
              command: |
                cat /etc/os-release
                apt update
                apt -y install wget
                wget -O - http://localhost/
    
    workflows:
    
      simple-run-test:
        jobs:
          - run-test-bridge
    

    输出是这样的:

    NAME="Ubuntu"
    VERSION="18.04.4 LTS (Bionic Beaver)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 18.04.4 LTS"
    VERSION_ID="18.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=bionic
    UBUNTU_CODENAME=bionic
    
    0% [Working]
    
    Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
    
    0% [Connecting to archive.ubuntu.com (91.189.88.142)] [1 InRelease 2586 B/88.7 
    
    0% [Connecting to archive.ubuntu.com (91.189.88.142)]
    
    0% [1 InRelease gpgv 88.7 kB] [Waiting for headers]
    
    Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
    
    0% [1 InRelease gpgv 88.7 kB] [2 InRelease 14.2 kB/242 kB 6%]
    
    0% [2 InRelease 14.2 kB/242 kB 6%]
    
    Get:3 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [854 kB]
    
    0% [2 InRelease 28.7 kB/242 kB 12%] [3 Packages 11.4 kB/854 kB 1%]
    
    0% [2 InRelease 43.1 kB/242 kB 18%]
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%] [Waiting for headers
    
    Get:4 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [8815 B]
    
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%] [4 Packages 8815 B/8
    
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%]
    
    Get:5 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [59.3 kB]
    
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%] [5 Packages 30.5 kB/
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%] [Waiting for headers
    
    Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [931 kB]
    
    0% [3 Packages store 0 B] [2 InRelease 43.1 kB/242 kB 18%] [6 Packages 36.5 kB/
    
    0% [3 Packages store 0 B] [2 InRelease 48.9 kB/242 kB 20%]
    
    0% [2 InRelease 92.4 kB/242 kB 38%]
    0% [4 Packages store 0 B] [2 InRelease 92.4 kB/242 kB 38%]
    
    0% [2 InRelease 92.4 kB/242 kB 38%]
    0% [5 Packages store 0 B] [2 InRelease 92.4 kB/242 kB 38%]
    
    0% [2 InRelease 101 kB/242 kB 42%]
    0% [6 Packages store 0 B] [2 InRelease 101 kB/242 kB 42%]
    
    0% [2 InRelease 205 kB/242 kB 85%]
    
    0% [Working]
    0% [2 InRelease gpgv 242 kB] [Waiting for headers]
    
    Get:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
    
    0% [2 InRelease gpgv 242 kB] [7 InRelease 2604 B/88.7 kB 3%]
    
    0% [2 InRelease gpgv 242 kB]
    
    0% [Waiting for headers]
    0% [7 InRelease gpgv 88.7 kB] [Waiting for headers]
    
    Get:8 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
    
    0% [7 InRelease gpgv 88.7 kB] [8 InRelease 2604 B/74.6 kB 3%]
    
    0% [7 InRelease gpgv 88.7 kB]
    
    0% [Waiting for headers]
    0% [8 InRelease gpgv 74.6 kB] [Waiting for headers]
    
    Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
    
    0% [8 InRelease gpgv 74.6 kB] [9 Packages 2685 B/1344 kB 0%]
    
    26% [9 Packages 213 kB/1344 kB 16%]
    
    31% [Waiting for headers]
    
    Get:10 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
    
    31% [10 Packages 3749 B/11.3 MB 0%]
    31% [9 Packages store 0 B] [10 Packages 3749 B/11.3 MB 0%]
    
    41% [10 Packages 2251 kB/11.3 MB 20%]
    
    82% [Working]
    
    Get:11 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]
    
    82% [11 Packages 16.0 kB/186 kB 9%]
    82% [10 Packages store 0 B] [11 Packages 16.0 kB/186 kB 9%]
    
    83% [10 Packages store 0 B] [Waiting for headers]
    
    Get:12 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
    
    83% [10 Packages store 0 B] [12 Packages 13.5 kB/13.5 kB 100%]
    
    83% [10 Packages store 0 B]
    
    Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [20.1 kB]
    
    83% [10 Packages store 0 B] [13 Packages 12.7 kB/20.1 kB 63%]
    
    83% [10 Packages store 0 B]
    
    Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1385 kB]
    
    83% [10 Packages store 0 B] [14 Packages 29.8 kB/1385 kB 2%]
    
    89% [10 Packages store 0 B] [Waiting for headers]
    
    Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [73.6 kB]
    
    89% [10 Packages store 0 B] [15 Packages 21.7 kB/73.6 kB 29%]
    
    89% [10 Packages store 0 B] [Waiting for headers]
    
    Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1228 kB]
    
    90% [10 Packages store 0 B] [16 Packages 20.2 kB/1228 kB 2%]
    
    95% [10 Packages store 0 B] [Waiting for headers]
    
    Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [8158 B]
    
    95% [10 Packages store 0 B] [17 Packages 8158 B/8158 B 100%]
    
    95% [10 Packages store 0 B]
    
    Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [8286 B]
    
    95% [10 Packages store 0 B] [18 Packages 8286 B/8286 B 100%]
    
    95% [10 Packages store 0 B]
    95% [10 Packages store 0 B]
    
    96% [Working]
    96% [11 Packages store 0 B]
    
    96% [Working]
    96% [12 Packages store 0 B]
    
    97% [Working]
    97% [13 Packages store 0 B]
    
    97% [Working]
    97% [14 Packages store 0 B]
    
    98% [Working]
    98% [15 Packages store 0 B]
    
    98% [Working]
    98% [16 Packages store 0 B]
    
    99% [Working]
    99% [17 Packages store 0 B]
    
    99% [Working]
    99% [18 Packages store 0 B]
    
    100% [Working]
    
    Fetched 18.0 MB in 3s (6556 kB/s)
    
    Reading package lists... 0%
    
    Reading package lists... 0%
    
    Reading package lists... 0%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 61%
    
    Reading package lists... 67%
    
    Reading package lists... 67%
    
    Reading package lists... 68%
    
    Reading package lists... 68%
    
    Reading package lists... 76%
    
    Reading package lists... 76%
    
    Reading package lists... 77%
    
    Reading package lists... 77%
    
    Reading package lists... 86%
    
    Reading package lists... 86%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... Done
    
    
    Building dependency tree... 0%
    
    Building dependency tree... 0%
    
    Building dependency tree... 0%
    
    Building dependency tree... 50%
    
    Building dependency tree... 50%
    
    Building dependency tree       
    
    
    Reading state information... 0%
    
    Reading state information... 0%
    
    Reading state information... Done
    
    4 packages can be upgraded. Run 'apt list --upgradable' to see them.
    
    Reading package lists... 0%
    
    Reading package lists... 0%
    
    Reading package lists... 0%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 7%
    
    Reading package lists... 63%
    
    Reading package lists... 67%
    
    Reading package lists... 67%
    
    Reading package lists... 68%
    
    Reading package lists... 68%
    
    Reading package lists... 76%
    
    Reading package lists... 76%
    
    Reading package lists... 77%
    
    Reading package lists... 77%
    
    Reading package lists... 86%
    
    Reading package lists... 86%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 87%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 93%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... 99%
    
    Reading package lists... Done
    
    
    Building dependency tree... 0%
    
    Building dependency tree... 0%
    
    Building dependency tree... 50%
    
    Building dependency tree... 50%
    
    Building dependency tree       
    
    
    Reading state information... 0%
    
    Reading state information... 0%
    
    Reading state information... Done
    
    The following additional packages will be installed:
      ca-certificates libpsl5 libssl1.1 openssl publicsuffix
    The following NEW packages will be installed:
      ca-certificates libpsl5 libssl1.1 openssl publicsuffix wget
    0 upgraded, 6 newly installed, 0 to remove and 4 not upgraded.
    Need to get 2521 kB of archives.
    After this operation, 7001 kB of additional disk space will be used.
    
    0% [Working]
    
    Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.6 [1301 kB]
    
    0% [1 libssl1.1 14.2 kB/1301 kB 1%]
    
    45% [Working]
    
    Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssl amd64 1.1.1-1ubuntu2.1~18.04.6 [614 kB]
    
    45% [2 openssl 9404 B/614 kB 2%]
    
    67% [Waiting for headers]
    
    Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 ca-certificates all 20180409 [151 kB]
    
    68% [3 ca-certificates 29.6 kB/151 kB 20%]
    
    76% [Waiting for headers]
    
    Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpsl5 amd64 0.19.1-5build1 [41.8 kB]
    
    76% [4 libpsl5 17.4 kB/41.8 kB 42%]
    
    80% [Working]
    
    Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 publicsuffix all 20180223.1310-1 [97.6 kB]
    
    81% [5 publicsuffix 23.1 kB/97.6 kB 24%]
    
    87% [Working]
    
    Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 wget amd64 1.19.4-1ubuntu2.2 [316 kB]
    
    87% [6 wget 21.3 kB/316 kB 7%]
    
    100% [Working]
    
    Fetched 2521 kB in 1s (3270 kB/s)
    debconf: delaying package configuration, since apt-utils is not installed
    Selecting previously unselected package libssl1.1:amd64.
    (Reading database ... 
    (Reading database ... 5%
    (Reading database ... 10%
    (Reading database ... 15%
    (Reading database ... 20%
    (Reading database ... 25%
    (Reading database ... 30%
    (Reading database ... 35%
    (Reading database ... 40%
    (Reading database ... 45%
    (Reading database ... 50%
    (Reading database ... 55%
    (Reading database ... 60%
    (Reading database ... 65%
    (Reading database ... 70%
    (Reading database ... 75%
    (Reading database ... 80%
    (Reading database ... 85%
    (Reading database ... 90%
    (Reading database ... 95%
    (Reading database ... 100%
    (Reading database ... 4046 files and directories currently installed.)
    Preparing to unpack .../0-libssl1.1_1.1.1-1ubuntu2.1~18.04.6_amd64.deb ...
    Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.6) ...
    Selecting previously unselected package openssl.
    Preparing to unpack .../1-openssl_1.1.1-1ubuntu2.1~18.04.6_amd64.deb ...
    Unpacking openssl (1.1.1-1ubuntu2.1~18.04.6) ...
    Selecting previously unselected package ca-certificates.
    Preparing to unpack .../2-ca-certificates_20180409_all.deb ...
    Unpacking ca-certificates (20180409) ...
    Selecting previously unselected package libpsl5:amd64.
    Preparing to unpack .../3-libpsl5_0.19.1-5build1_amd64.deb ...
    Unpacking libpsl5:amd64 (0.19.1-5build1) ...
    Selecting previously unselected package publicsuffix.
    Preparing to unpack .../4-publicsuffix_20180223.1310-1_all.deb ...
    Unpacking publicsuffix (20180223.1310-1) ...
    Selecting previously unselected package wget.
    Preparing to unpack .../5-wget_1.19.4-1ubuntu2.2_amd64.deb ...
    Unpacking wget (1.19.4-1ubuntu2.2) ...
    Setting up libpsl5:amd64 (0.19.1-5build1) ...
    Setting up publicsuffix (20180223.1310-1) ...
    Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.6) ...
    debconf: unable to initialize frontend: Dialog
    debconf: (TERM is not set, so the dialog frontend is not usable.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
    debconf: falling back to frontend: Teletype
    Setting up openssl (1.1.1-1ubuntu2.1~18.04.6) ...
    Setting up wget (1.19.4-1ubuntu2.2) ...
    Setting up ca-certificates (20180409) ...
    debconf: unable to initialize frontend: Dialog
    debconf: (TERM is not set, so the dialog frontend is not usable.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
    debconf: falling back to frontend: Teletype
    Updating certificates in /etc/ssl/certs...
    133 added, 0 removed; done.
    Processing triggers for libc-bin (2.27-3ubuntu1) ...
    Processing triggers for ca-certificates (20180409) ...
    Updating certificates in /etc/ssl/certs...
    0 added, 0 removed; done.
    Running hooks in /etc/ca-certificates/update.d...
    done.
    --2020-05-30 21:50:35--  http://localhost/
    Resolving localhost (localhost)... 127.0.0.1, 127.0.0.1, ::1
    Connecting to localhost (localhost)|127.0.0.1|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 612 [text/html]
    Saving to: 'STDOUT'
    
    
    -                     0%[                    ]       0  --.-KB/s               <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
            width: 35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    
    -                   100%[===================>]     612  --.-KB/s    in 0s      
    
    2020-05-30 21:50:35 (101 MB/s) - written to stdout [612/612]
    
    

    注意一开始,我们展示了手鼓的版本。这是cat /etc/os-release配置中的一个。

    最后,显示 Web 服务器的欢迎页面。只是结果wget -O - http://localhost/,事实上wget -O - http://localhost:80

    • 0

相关问题

  • 如果 fuser -k number/tcp 没有帮助,如何在 Debian 中释放端口?

  • Ubuntu。startx 不起作用。黑屏

  • --syn 在 iptables 中有什么作用?

  • 为什么需要iso格式?

  • C程序中没有密码的sudo

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    如何从列表中打印最大元素(str 类型)的长度?

    • 2 个回答
  • Marko Smith

    如何在 PyQT5 中清除 QFrame 的内容

    • 1 个回答
  • Marko Smith

    如何将具有特定字符的字符串拆分为两个不同的列表?

    • 2 个回答
  • Marko Smith

    导航栏活动元素

    • 1 个回答
  • Marko Smith

    是否可以将文本放入数组中?[关闭]

    • 1 个回答
  • Marko Smith

    如何一次用多个分隔符拆分字符串?

    • 1 个回答
  • Marko Smith

    如何通过 ClassPath 创建 InputStream?

    • 2 个回答
  • Marko Smith

    在一个查询中连接多个表

    • 1 个回答
  • Marko Smith

    对列表列表中的所有值求和

    • 3 个回答
  • Marko Smith

    如何对齐 string.Format 中的列?

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5