Connecting a freshly built container to one of the existing ones


#1

The examples and content on Discuss are showing how to use an existing MySQL image from the primary container. Though I would like to connect to it from a freshly build container and I can’t figure how.

version: 2
jobs:
  build:
    docker:
      - image: circleci/python:2.7.13
      - image: library/mysql:5.7.17
        env:
            - MYSQL_ALLOW_EMPTY_PASSWORD=true
            - MYSQL_ROOT_HOST=%
    working_directory: ~/project
    steps:
      - checkout
      - setup_remote_docker

      - run: |
          sudo apt-get -q update
          sudo apt-get -q install -y mysql-client
          # Here i can connect to MySQL on 127.0.0.1 using mysql

      - run: |
            docker build -t base -f ./docker/Dockerfile.base .
            docker run --network host  --name test base tail -f /dev/null
            # Here i can't connect to MySQL on 127.0.0.1 using mysql inside the freshly running environment

#2

You can’t. Bring up a new MySQL container in the same network as base.


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.