TheDoctor
TheDoctor

Reputation: 2512

Docker exposing ports site can't be reached

I have exposed the required ports in my dockerfiles as well mapped them in my docker-compose.yml.

If i create containers without a docker-compose.yml i can access everything, but if i use docker-compose.yml file i cannot access 2 out of 3 images via a http-get request.

But according to docker port <container-name> the ports are mapped:

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

I don't know why i cannot access the phpmyadmin-container and the php-container but the comp-container if i use a docker-compose file.

Did i miss something important?

php-image:

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-image:

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-image:

FROM phpmyadmin/phpmyadmin
EXPOSE 8090

docker-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

Upvotes: 0

Views: 6976

Answers (1)

TheDoctor
TheDoctor

Reputation: 2512

The solution was to change the ports from admin and php from "8080:8080" and "8090:8080" to "8080:80" and "8090:80" respectively.

Upvotes: 2

Related Questions