0

I am trying to create a container with docker-compose so I ran docker-compose up on the following compose file:

services:
  mysql:
    image: mysql:5.7
    ports:
        - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_USER: admin 
        MYSQL_PASSWORD: joesam007#
        MYSQL_DATABASE: Woodcore-test

After pulling and building the image, while trying to create the db, the error response shows thus:

Creating microservice-task_mysql_1 ... 
Creating microservice-task_mysql_1 ... error

ERROR: for microservice-task_mysql_1  Cannot start service mysql: driver failed programming external connectivity on endpoint microservice-task_mysql_1 (3f2a9ad024c6e586a9c7f089a388cecf7decbf7870106b5b34e5a21e88b415a3): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use

I'd like to know how to handle this issue and create the db successfully. Please help, thanks.

1
  • 1
    listen tcp4 0.0.0.0:3306: bind: address already in use: make sure you don't have another service or app running on this port. Commented Feb 9, 2021 at 23:22

1 Answer 1

1

Sounds like you are running an existing MySQL Database on your host port 3306. You can confirm via the following command:

Windows: netstat -a | findstr :3306
Linux: netstat -a | grep :3306

If you don't want to stop that Database/Service consuming that port, you can always change the host port which it binds to by updating your docker-compose config file to:

- "3307:3306"

This will then let you connect to the containers database on port 3307 from the host machine.

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome. It worked when I changed the host port. But I still have issues running my microservice, can I show you that as well?
Sure, might be best to create a new question unless it is a similar error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.