thewca / worldcubeassociation.org

All of the code that runs on worldcubeassociation.org
https://www.worldcubeassociation.org/
GNU General Public License v3.0
320 stars 175 forks source link

How to run locally on a system that has other databases on it #8853

Open chunter2 opened 6 months ago

chunter2 commented 6 months ago

I'm trying to run the site locally by cloning the repo and using docker-compose up but get the following errors. This is on a Ubuntu 22.04 server that already has other mysql databases on it.

Starting database ...
mailcatcher is up-to-date
redis-main is up-to-date
Starting database ... error

ERROR: for database  Cannot start service wca_db: driver failed programming external connectivity on endpoint database (8804e35b3720415ca17c710397a791c2c3f1004b03381f8a5fbcc755a9259ad5): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use

ERROR: for wca_db  Cannot start service wca_db: driver failed programming external connectivity on endpoint database (8804e35b3720415ca17c710397a791c2c3f1004b03381f8a5fbcc755a9259ad5): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use
ERROR: Encountered errors while bringing up the project.

Is there a way to run and use the existing database that's already running?

Thanks

chunter2 commented 6 months ago

I was able to get this working with the help of a coworker. He suggested changing lines 110 and 111 in the docker-compose.yml file to the following and it worked.

    expose:
      - "3306"

Not sure if this should be the default but just posting for others.

dunkOnIT commented 5 months ago

@FinnIckler what do you think of this change? Would it not be the case that this conflict only occurs if there are other containers live at the same time as one is trying to spin up the WCA container?

gregorbg commented 5 months ago

Not Finn but the problem here is clearly the ports. Most database systems, no matter whether you're running them inside or outside a container, are trying to bind their servers to port 3306 by default.

Our Docker image is configured so that it "exposes" port 3306 of the database container to the outside world host system, with the intention of being able to connect DB GUI explorers like DataGrip or DBeaver to the WCA ecosystem.

The solution here is to either gracefully pause the server running on the local machine, then boot up our Docker zoo, or to change the docker-compose YAML to expose the port only internally within the Docker network but not to the host machine. (If you do the latter, you won't be able to connect GUIs from your PC to our WCA DB server)