无法启动服务 www:驱动程序无法在端点上编程外部连接

Cannot start service www: driver failed programming external connectivity on endpoint

提问人:user3523406 提问时间:3/19/2018 最后编辑:user3523406 更新时间:3/20/2018 访问量:2350

问:

我在这里将这个原始项目转换为 docker-compose 项目,并按照他们的设置说明进行操作。似乎我无法与浏览器连接。

SQL 文件包含数据库架构,如下所示:

CREATE DATABASE mgsv;
CREATE USER 'mgsv_user'@'localhost' IDENTIFIED BY 'mgsvpass';
GRANT SELECT, INSERT, CREATE, DROP ON mgsv.* TO 'mgsvuser'@'localhost';
use mgsv;
CREATE TABLE IF NOT EXISTS `userinfo` (
    `id` int(10) NOT NULL AUTO_INCREMENT,
    `email` text NOT NULL,
    `hash` text NOT NULL,
    `synfilename` text NOT NULL,
    `annfilename` text NOT NULL,
    `url` text NOT NULL,
    `session_id` text NOT NULL,
    `annImage`   int(5) NOT NULL,
    `create_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

docker-compose.yml如下所示:

version: '3.1'

services:
  db:
    image: mysql
    restart: always
    environment:
      - MYSQL_DATABASE=mgsv
      - MYSQL_USER=mgsv_user
      - MYSQL_PASSWORD=mgsvpass
      - MYSQL_ROOT_PASSWORD=mysql123
    volumes:
      - ./mysql:/docker-entrypoint-initdb.d

  www:
    build: ./mGSV 
    restart: always
    ports:
      - 8080:8080

Dockerfile 包含 PHP 和所有其他工具设置,如下所示。

FROM php:5-apache

RUN apt-get update  && apt-get install -y --no-install-recommends \
                openjdk-7-jdk \
                maven  \
        git \
        && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/qunfengdong/mGSV.git

# Move the folder 'mgsv' to DocumentRoot of Apache web server. By default, the DocumentRoot of Apache is /var/www/ (speak to the system administrator to know the exact DocumentRoot).
RUN cd /var/www/html/mGSV \
    && mkdir tmp \
    && chmod -R 777 tmp

RUN cd /var/www/html/mGSV && sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php \ 
    && sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php \
    && sed -i.bak "s|cas-qshare.cas.unt.edu|localhost|" lib/settings.php

RUN cp /var/www/html/mGSV/Arial.ttf /usr/share/fonts/truetype/

#Do not understand
#7. Cleanup scripts are provided to drop database synteny and annotation tables, remove entries from database table 'userinfo' and delete the folder containing image files which are older than 60 days. This task is accomplished by cron job to run the cleanup script every day. To create a cron job, use the command below:
#   shell> crontab -e

#At the last line of crontab, copy and paste the line below, and provide the exact path to mgsv/lib/cleanup.php
#   30 04 * * * /var/www/mgsv/lib/cleanup.php

#The script cleanup.php will be executed at 4:30 AM every morning.

#8. mGSV uses the mail function from PHP to send email to users. Speak to your system administrator to provide required information in the PHP configuration file called 'php.ini'.

#9. When installation completes, you can now open Install/index.php (i.e., http://<YOUR_SERVER_DOMAIN_NAME>/mgsv/Install/), which verifies prerequisites, database setup, and installation. YOUR_SERVER_DOMAIN_NAME refers to the domain name of your server.


RUN cd /var/www/html/mGSV/ws \
    && tar -xzf mgsv-ws-server.tar.gz

RUN cd /var/www/html/mGSV/ws/mgsv-ws-server \ 
    && mvn package

RUN cp -f /var/www/html/mGSV/ws/mgsv-ws-server/target/ws-server-1.0RC1-jar-with-dependencies.jar /var/www/html/mGSV/ws/

RUN cd /var/www/html/mGSV/ws \ 
    && echo "mgsv_upload_url=http://localhost/mgsv" > config.properties \
    && echo "ws_publish_url=http\://localhost\:8081/MGSVService" >> config.properties \
    && java -jar ws-server-1.0RC1-jar-with-dependencies.jar &

#To stop the web service
#shell> ps aux | grep ws-server-1.0RC1-jar-with-dependencies.jar
#*Note the process id from the output*
#shell> kill -9 <process id>

这是我得到的输出:

Successfully tagged mgsvdocker_www:latest
Starting mgsvdocker_www_1 ... 
mgsvdocker_db_1 is up-to-date
Starting mgsvdocker_www_1 ... error

ERROR: for mgsvdocker_www_1  Cannot start service www: driver failed programming external connectivity on endpoint mgsvdocker_www_1 (37d78703b379b65521d9fc15d2d1d51379f7eee71f7dc912585e088d8bf1b4e9): Bind for 0.0.0.0:8080 failed: port is already allocated

ERROR: for www  Cannot start service www: driver failed programming external connectivity on endpoint mgsvdocker_www_1 (37d78703b379b65521d9fc15d2d1d51379f7eee71f7dc912585e088d8bf1b4e9): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

我不太确定我是否在 Dockerfile 中的docker-compose.yml文件或数据库配置中犯了错误。

无论如何,有人知道我错过了什么吗?

先谢谢你

java php mysql docker docker-compose

评论

1赞 Robert Moskal 3/19/2018
嗨,欢迎来到SO。请参阅此处,了解如何制作可能获得答案的问题:stackoverflow.com/help/how-to-ask。首先,您应该在问题正文中发布代码和错误消息。
0赞 user3523406 3/19/2018
谢谢,我按照您的建议更新了我的问题。
0赞 Robert Moskal 3/19/2018
您已经在端口 8080 上运行了某些内容!
0赞 user3523406 3/19/2018
我将其更改为端口 8000,但现在我得到了此输出
0赞 user3523406 3/19/2018
p.s. 我应该使用哪个 IP 地址?

答: 暂无答案