Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-Compose: Only one usage of each socket address (protocol/network address/port) is normally permitted

I'm trying to run docker-compose.yml from here: https://github.com/Project-Books/book-project#running-the-app.

I tried to run a docker-compose file in Intellij IDEA Community Edition - using Docker plugin 202.7319.5

Here's the docker-compose.yaml file used: https://github.com/Project-Books/book-project/blob/master/docker-compose.yml

Here's the details about Docker Desktop installed:

OS: Windows
Version: 2.3.0.4(46911)
Channel: Stable
Engine: 19.03.12
Compose: 1.26.2

Output I'm getting in the console:

ERROR: for book-project_mysql_1  Cannot start service mysql: Ports are not available: listen tcp 0.0.0.0:3306: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
ERROR: for mysql  Cannot start service mysql: Ports are not available: listen tcp 0.0.0.0:3306: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
Encountered errors while bringing up the project.
like image 973
Dhannanjai Avatar asked Oct 11 '20 17:10

Dhannanjai


2 Answers

The port 3306 is already in use by other application. You can deploy MySQL to another port.

example docker-compose:

version: '3'

services:
  mysql:
    image: mysql:latest
    hostname: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: bookproject
      MYSQL_USER: dbuser
      MYSQL_PASSWORD: dbpassword
    ports:
      - "3307:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./src/main/resources/db/init.sql:/data/application/init.sql
    command: --init-file /data/application/init.sql
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    links:
      - mysql:db
    ports:
      - "8081:80"
  bookapp:
    build: ./
    restart: on-failure      
    ports: 
      - "8080:8080"
    environment:
      - WAIT_HOSTS=mysql:3307
      - WAIT_HOSTS_TIMEOUT=300
      - WAIT_SLEEP_INTERVAL=30
      - WAIT_HOST_CONNECT_TIMEOUT=30
      #- DEFAULT_PATH=<Target path in windows> 
    depends_on:
      - mysql
      - phpmyadmin
volumes:
  db_data:
like image 137
n0nvme Avatar answered Sep 17 '22 16:09

n0nvme


I solved the problem by ending the "mysqld.exe" process in the task manager. Because this process has occupied port 3306.

First i had to find out which programme was using the port. The windows integrated gui of the resource monitor helped me here.

This Post helped me

like image 29
GJC Avatar answered Sep 19 '22 16:09

GJC