无法访问Docker暴露端口站点

时间:2016-08-26 13:03:31

标签: docker docker-compose ports get-request

我已经在我的dockerfiles中公开了所需的端口,并将它们映射到我的docker-compose.yml

如果我创建没有docker-compose.yml的容器,我可以访问所有内容,但是如果我使用docker-compose.yml文件,则无法通过http-get请求访问3个图像中的2个。

但根据docker port <container-name>端口已映射:

bitmovin @bitmovin-VirtualBox:〜/ Documents $ docker port php-container 8080:

0.0.0.0:8080

bitmovin @bitmovin-VirtualBox:〜/ Documents $ docker port php-container:

8080/tcp -> 0.0.0.0:8080

bitmovin @bitmovin-VirtualBox:〜/ Documents $ docker port comp-container:

8080/tcp -> 0.0.0.0:8070

bitmovin @bitmovin-VirtualBox:〜/ Documents $ docker port phpmyadmin-container:

8080/tcp -> 0.0.0.0:8090

如果我使用phpmyadmin-container文件,我不知道为什么我无法访问php-containercomp-container,而docker-compose无法访问。

我是否错过了重要的事情?

PHP-图像:

FROM php:7.0-apache

EXPOSE 8080

COPY Frontend/ /var/www/html/aw3somevideo/
COPY Frontend/ /var/www/html/

RUN chown -R www-data:www-data /var/www/html 
RUN chmod -R 755 /var/www/html 

RUN docker-php-ext-install mysqli 
RUN php -i | grep -F .default_socket

COMP-图像:

FROM java:openjdk-8u91-jdk
EXPOSE 8070
CMD java -jar encoding-comparison-1.0.jar
ADD encoding-comparison-1.0.jar  /encoding-comparison-1.0.jar

phpmyadmin的图像:

FROM phpmyadmin/phpmyadmin
EXPOSE 8090

搬运工-compose.yml:

db:
    image: mysql-image
    ports:
     - "3306:3306"
    volumes:
     - /var/lib/mysql
    environment:
     - MYSQL_ROOT_PASSWORD=Bitmovin
     - DB_NAME=aw3somevideo
     - DB_USER=Bitmovin
     - DB_PASS=Bitmovin
    container_name: mysql-container

  admin:
    image: phpmyadmin-image
    ports:
      - "8090:8080"
    links:
      - db
    container_name: phpmyadmin-container

  backend:
    image: comp-image
    ports:
      - "8070:8080"
    volumes:
      - ./src:/var/www/backend
    links:
      - db
    container_name: comp-container

  php:
    image: php-image
    volumes:
      - ./src:/var/www/html
    links:
      - db
    ports:
      - "8080:8080"
    container_name: php-container

1 个答案:

答案 0 :(得分:2)

解决方案是将端口从adminphp分别从"8080:8080""8090:8080"更改为"8080:80""8090:80"