Running commands on docker container


I have the following circle config:

      # specify the version you desire here
      - image: circleci/php:7.1-browsers
      - image: swaggerapi/swagger-codegen-cli:2.4.5
      - image: circleci/mysql:5.7
          MYSQL_DATABASE: circleci
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at
      # - image: circleci/mysql:9.4

    working_directory: ~/repo

swagger-codegen-cli is a CLI that I use to generate api sdk’s based off of my swagger documentation. Mysql is easy to use because it binds to port 3306, but I’m struggling with how to execute commands using that container. Any guidance you could give me would be fantastic

You can’t. Run steps will only run within the primary container, which is the first image listed in the config. All additional containers are only accessible via TCP/IP.

You’d want to get that CLI installed in the primary image.

I use that Swagger image too. The easiest way to run it is probably to install Docker in your primary container and then docker run it from there. Alternatively, you can install it by grabbing the jar file and installing Java, but Docker might be quicker :grinning: