I am configuring the docker to my projects in the VPS server for the first time. I successfully run it on a local machine but in the server, all services are running but not accessible through the browser. I checked all the port mapping, firewall configurations, and lots of blogs and tutorials but nothing help me out.
Below is the structure of my project:
- html/
- Dockerfile
- docker-compose.yml
- projects (ie. oms)
Here are my configuration files,
docker-compose.yml
version: '3'
services:
oms:
build:
context: . # automatically finds Dockerfile
dockerfile: Dockerfile
container_name: oms
ports:
- 8080:80
volumes:
- "./oms:/var/www/html/oms"
links:
- db
db:
image: mariadb:10.6.13
restart: always
environment:
- MARIADB_ROOT_PASSWORD=root #username = root
volumes:
- db:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8001:80
environment:
- PMA_HOST:db
- PMA_PORT:3306
volumes:
db:
Here is my Dockerfile
FROM php:8.1-apache
RUN apt-get update -y \
&& apt-get install -y \
libpng-dev \
libjpeg-dev \
&& docker-php-ext-configure gd --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& apt-get install -y default-mysql-client \
&& docker-php-ext-install mysqli \
&& docker-php-ext-enable mysqli \
&& apt-get install -y git \
&& apt-get install -y nano \
&& apt-get install -y iputils-ping
# Give permissions to www-data user
RUN chown -R www-data:www-data /var/www/html
# Enable rewrite module
RUN a2enmod rewrite
# Copy the project files for projects(ie office1, office2..)
COPY ./ /var/www/html/
# Set the working directory
WORKDIR /var/www/html
# Restart Apache service
CMD ["apache2-foreground"]
when i try to access through browser using url http://ip:8001 or http://ip:8080, it throw me this error
I checked whether the port is blocked or not by the firewall using the command:
- telnet vps_ip 8080
- telnet vps_ip 8001
both ports are connected
Also, when I login into the VPS server and curl -i localhost:8001 in the terminal it displays contents but not in the browser. I don't know what I am missing. Can somebody please help me out?