Launching service in Docker container and connecting from primary

I’m having trouble figuring out how to connect to an SFTP server I want to run as part of my docker setup. Here is the configuration that I"m using to launch the SFTP container:

  - run:
      name: Run Docker FTP test server
      command: |
        docker run --restart=always \
                   -p 2222:22 \
                   --name sftp_test_server \
                   -d atmoz/sftp foo:pass:::from_no

I’m having trouble connecting to it from my main app. How do I find the hostname for this container and make sure it’s in the same network? When my test suite runs my app can’t find this service.

If you run this image inside the image section of your YAML config file, it may be easier - CircleCI exposes secondary container listeners on localhost.

Alternatively you could put your FTP server and your main app in separate containers and run them both using Docker Compose. That’s what I do, and it works fine.

Your approach of using docker run should work, but you’d need to find what IP it attaches to - perhaps you could SSH in and use nstat?

How can I ssh into the container and use nstat? I haven’t done that before and not sure how to do it on CircleCI

To use Nstat, you just need to search and say what you want to do.

To use SSH, find a failed job in the CircleCI user interface, click into the detail view, and click “Rerun job with SSH”.

Thanks for the info on nstat. This is the solution that I found works for what I’m trying to do:


      - image: atmoz/sftp
        command: ["foo:pass:::from_no"]
1 Like

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