Error starting userland proxy: listen tcp bind: address already in


Hi there,

I am using a docker-compose file that runs my dockerized app and a MySql DB.
The MySql Image exposes port 3306, however I keep getting this error when trying to bring it up:

ERROR: for db  Cannot start service db: driver failed programming external connectivity on endpoint myrepo_db_1 (dc420fc36e196cfa9ac1e4ed70bf1a513fad39231ba11f0d05b6d16d066551c0): Error starting userland proxy: listen tcp bind: address already in use
ERROR: Encountered errors while bringing up the project.

My suspition is that CircleCI already has a MySql instance runnign to “help” me. Is there a way I can disable it?

I am using the Ruby 2.3 base image on the DockerExecutor.

version: 2
executorType: docker
      - image: ruby:2.3


You can run netstat -plntua or ss -plntua to check open ports but it’s not running by default.

Do you have the necessary dependencies installed? I advise building your own base image.


I’ll check the result of netstat -plntua. About the dependencies, The only thing I need is docker and docker-compose, as well as ruby and gem to install a deployment CLI (kontena).


So the output of ss-plntua is the following:

ss -plntua
Shell: /bin/bash -eo pipefail

Netid  State      Recv-Q Send-Q     Local Address:Port       Peer Address:Port 
udp    UNCONN     0      0                    *:*     
tcp    LISTEN     0      128                  *:*     
tcp    TIME-WAIT  0      0       
tcp    ESTAB      0      0      users:(("picard",pid=13,fd=4))
tcp    TIME-WAIT  0      0      
tcp    TIME-WAIT  0      0       

The port is not in use, but somehow I still get the error. Any idea what might be causing it?


What do you get from docker ps -a before spinning up your MySQL container?


Not much unfortunately.


However I am spinning up my containers using docker-compose up -d --force-recreate. Could the --force-recreate have an impact on the underlying build env?


I guess so if you’re hitting that error


I tried again without --force-recreate and still get the error.
Could any of you try to see if you can reproduce the error? This docker-compose command is running fine on all other CIs tools I am trying atm.

Below is my docker-compose.yml, the app in itself does not matter much since the linked db service won’t start.

Here is a minimal config that I use to reproduce:


version: 2
executorType: docker
      - image: ruby:2.3
    working_directory: ~/12grapes
      - checkout
      - setup_docker_engine
      # This should go into custom primary image, here's only for the sake of explanation
      - run:
          name: Install Docker client
          command: |
            set -x
            curl -L -o /tmp/docker-$VER.tgz$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin
      - run:
          name: Install Docker Compose
          command: |
            set -x
            curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose
            chmod +x /usr/local/bin/docker-compose
      - run: ss -plntua
      - run: docker ps -a
      - run: docker-compose up -d


version: '2'
    image: mysql:5.7.7
        - '3306'
        - "3306:3306"
      context: .
      dockerfile: Dockerfile
      - db


@superzadeh the problem was in our image we are using for Remote Docker, we’ve fixed it, you should be able to run your build now.

Side note, to give some perspective why ss -plntua didn’t show anything using port 3306 - all the commands are executed in your primary container (ruby:2.3) at the same time containers you are starting with docker-compose are running in Remote Docker Environment. You can read more in our docs.


@smaantci Thanks for the reply, I’ll give this another shot later since for now I have moved to another CI tool.

The explanation makes perfect sense. Maybe detailing more what’s running in the image of the Remote Docker environment would help in troubleshooting these issues.