Docker Community Forums

Share and learn in the Docker community.

Why in docker adminer failed with port address already in use error?

Hello,
Installing laravel app under docker from FROM php:7.2-apache
I got errors that start service adminer failed and port address already in use:

Creating gotoconsult_adminer ...
Creating gotoconsult_adminer ... error

ERROR: for gotoconsult_adminer  Cannot start service adminer: driver failed programming external connectivity on endpoint gotoconsult_adminer (06771e791ffbd3a04af81f13f8a6a885c9dd11e8031aa34bb9a2a037fbfdfc3e): Error starting userland proxy: listen tcp 0.0.0.0:8089: bind: address already in use

ERROR: for adminer  Cannot start service adminer: driver failed programming external connectivity on endpoint gotoconsult_adminer (06771e791ffbd3a04af81f13f8a6a885c9dd11e8031aa34bb9a2a037fbfdfc3e): Error starting userland proxy: listen tcp 0.0.0.0:8089: bind: address already in use
ERROR: Encountered errors while bringing up the project.

I stop docker :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name/__DOCKER$ docker-compose down
Stopping gotoconsult_db  ... done
Stopping gotoconsult_web ... done
Removing gotoconsult_adminer  ... done
Removing gotoconsult_db       ... done
Removing gotoconsult_web      ... done
Removing gotoconsult_composer ... done
Removing network docker_default

and check empty containers list :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name/__DOCKER$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

I run next :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name/__DOCKER$ ps uax | grep mysql
mysql     1670  0.0  0.5 1361220 42796 ?       Sl   16:25   0:02 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
serge     4097  0.0  0.1 2554892 8504 ?        Sl   16:25   0:02 /usr/sbin/mysqld --defaults-file=/home/serge/.local/share/akonadi/mysql.conf --datadir=/home/serge/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-serge.wsi8ij/mysql.socket --pid-file=/tmp/akonadi-serge.wsi8ij/mysql.pid
999      13286  0.0  0.5 1078304 42036 ?       Ssl  16:32   0:02 mysqld
serge    15672  0.0  0.0  18008   972 pts/3    S+   17:51   0:00 grep --color=auto mysql

Not sure which mysql is it? I have running apache2 with mysql on my hosting Ubuntu 18? Can it be the issue?

and running composer again I got error :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name/__DOCKER$ docker-compose up -d
Creating network "docker_default" with the default driver
Creating gotoconsult_web ...
Creating gotoconsult_db ...
Creating gotoconsult_composer ...
Creating gotoconsult_web
Creating gotoconsult_composer
Creating gotoconsult_db ... done
Creating gotoconsult_adminer ...
Creating gotoconsult_adminer ... error

ERROR: for gotoconsult_adminer  Cannot start service adminer: driver failed programming external connectivity on endpoint gotoconsult_adminer (aafcc2af19f6589c62586dbc3b9c57562b6416f7500cdf0b40a37052d138da3b): Error starting userland proxy: listen tcp 0.0.0.0:8089: bind: address already in use

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

In my __DOCKER/docker-compose.yml I have :

    adminer:
      container_name: project_name_adminer
      image: adminer
      restart: always
      ports:
        - 8089:8080
      links:
        - db

Why error and how to fix it?

The port is already in use:

Change the left hand side of your port mapping to a free port:

I have no any docker comtainers in my OS and I tried to kill process of a
used port and after ubuntu 18 restarted I run docker again :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ systemctl restart docker
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ docker-compose up -d
Starting container_web ...
Starting container_composer ...
Starting container_composer
container_db is up-to-date
Starting container_web
Starting container_adminer ...
Starting container_web ... done
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ docker logs --tail=40  -t  container_db
2020-12-12T04:27:13.866591595Z 2020-12-12T04:27:13.866463Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2020-12-12T04:27:13.866619557Z 2020-12-12T04:27:13.866504Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2020-12-12T04:27:14.866684276Z 2020-12-12T04:27:14.866593Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11

I make checks :

netstat -lpn | grep 8089
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::8089                 :::*                    LISTEN      -

Trying o kill this process:

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ sudo lsof -t -i:8089
11974
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ sudo kill -9 11974

Check that all is cleared :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ sudo lsof -t -i:8089
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ netstat -lpn | grep 8089
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)

And the same error running docker again :

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ docker-compose up -d
container_web is up-to-date
Starting container_composer ...
container_db is up-to-date
Starting container_composer
Starting container_composer ... done
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ docker logs --tail=40  -t  container_web
2020-12-11T15:51:27.153557880Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.3. Set the 'ServerName' directive globally to suppress this message
2020-12-11T15:51:27.173414849Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.3. Set the 'ServerName' directive globally to suppress this message
2020-12-11T15:51:27.221060829Z [Fri Dec 11 15:51:27.220631 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.2.34 configured -- resuming normal operations
2020-12-11T15:51:27.221095154Z [Fri Dec 11 15:51:27.220916 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
2020-12-11T16:13:55.435812735Z 172.22.0.3:80 172.22.0.1 - - [11/Dec/2020:16:13:55 +0000] "GET /wallet HTTP/1.1" 200 509 "http://127.0.0.1:8088/transactions" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
2020-12-11T16:13:55.887374112Z 172.22.0.3:80 172.22.0.1 - - [11/Dec/2020:16:13:55 +0000] "GET /favicon.ico HTTP/1.1" 304 178 "http://127.0.0.1:8088/wallet" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
2020-12-11T16:14:46.981847045Z 172.22.0.3:80 172.22.0.1 - - [11/Dec/2020:16:14:46 +0000] "-" 408 0 "-" "-"
2020-12-11T16:25:37.016476912Z [Fri Dec 11 16:25:37.001024 2020] [mpm_prefork:notice] [pid 1] AH00170: caught SIGWINCH, shutting down gracefully
2020-12-12T04:26:36.584784428Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.5. Set the 'ServerName' directive globally to suppress this message
2020-12-12T04:26:36.703910666Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.5. Set the 'ServerName' directive globally to suppress this message
2020-12-12T04:26:36.904703169Z [Sat Dec 12 04:26:36.904401 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.2.34 configured -- resuming normal operations
2020-12-12T04:26:36.904726552Z [Sat Dec 12 04:26:36.904638 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name__DOCKER$ docker logs --tail=40  -t  container_db
2020-12-12T04:33:11.960345116Z 2020-12-12T04:33:11.960225Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2020-12-12T04:33:11.960379414Z 2020-12-12T04:33:11.960255Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2020-12-12T04:33:12.960599392Z 2020-12-12T04:33:12.960422Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11

again check ports :

$ sudo lsof -t -i:8089
17620
and :
erge@AtHome:/mnt/_work_sdb8/wwwroot/lar/project_name/__DOCKER$ ps uax | grep mysql
mysql     1745  0.0  1.4 1426956 115216 ?      Sl   06:17   0:01 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
serge     4412  0.0  2.1 2554892 171268 ?      Sl   06:17   0:01 /usr/sbin/mysqld --defaults-file=/home/serge/.local/share/akonadi/mysql.conf --datadir=/home/serge/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-serge.jyO3Cq/mysql.socket --pid-file=/tmp/akonadi-serge.jyO3Cq/mysql.pid
999      11112  0.0  1.4 1078304 117536 ?      Ssl  06:24   0:01 mysqld
999      21312  1.3  2.1 562796 177700 ?       Ssl  06:52   0:00 mysqld
serge    21481  0.0  0.0  18008  1020 pts/3    S+   06:52   0:00 grep --color=auto mysql

and again the same :

sudo kill -9 17620

and the same error running again :

docker-compose up -d

$ docker logs --tail=40  -t  container_db
2020-12-12T04:59:43.634814622Z 2020-12-12T04:59:43.634657Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2020-12-12T04:59:43.634853715Z 2020-12-12T04:59:43.634686Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
...

All the command I run in hosting Kubuntu 18.

I do not see why stopping compose and killing process I got error again?
Is something wrong in my config files?

__DOCKER/docker-compose.yml :

version: '3.5'

services:


    web:
        container_name: container_web

        build:
            context: ./web
            dockerfile: Dockerfile.yml

        environment:
            - APACHE_RUN_USER=www-data
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        ports:
            - 8088:80
        working_dir: ${APP_PTH_CONTAINER}


    db:
        container_name: container_db
        image: mysql:5.7.28
        # image: mysql:8.0.21
        restart: always
        environment:
            - MYSQL_DATABASE=DockerDB
            - MYSQL_USER=docker_user
            - MYSQL_PASSWORD=4321
            - MYSQL_ALLOW_EMPTY_PASSWORD=false
            - MYSQL_ROOT_PASSWORD=321
            - TZ=Europe/Kiev

        volumes:
            - ${DB_PATH_HOST}:/var/lib/mysql



    adminer:
      container_name: container_adminer
      image: adminer
      restart: always
      ports:
        - 8089:8080
      links:
        - db


    composer:
        container_name: container_composer
        image: composer:1.8
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

and __DOCKER/web/Dockerfile.yml:

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y \
    python \
    libfreetype6-dev \
    libwebp-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libzip-dev \
    nano \
    mc \
    git-core \

#    libmagickwand-dev --no-install-recommends && \
#    pecl install imagick && imagick && \
#    docker-php-ext-enable imagick && \

    curl \
    build-essential \
    openssl \
    libssl-dev \
    libgmp-dev \
    libldap2-dev \
    netcat \
    locate \
    # composer \
    && git clone https://github.com/nodejs/node.git && \
  cd node  \
  && git checkout v12.0.0 \
  && ./configure \
  && make \
  && make install

  RUN npm install cross-env

  RUN npm install -g yarn

  RUN  docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/

  RUN apt-get install -y zlib1g-dev libicu-dev g++ \
  && docker-php-ext-configure intl \
  && docker-php-ext-install intl

  # Install Composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

  RUN  docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif  \
&& a2enmod rewrite

  # RUN install-php-extensions imagick

COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf

?

Thanks!