I have an app running on docker
. I am gonna deploy it to ubuntu server
.
So I want that when i call domain or ip from browser (ex: mydomain.com)
it displays my app in browser.
What configuration should I do in docker or apache
conf. file?
Thank you!
CodePudding user response:
The answer depends on many details you did not provide about your application.
In general you should write a docker compose file like this:
version: "3.5"
services:
nginx:
container_name: my-app
image: ubuntu:latest
hostname: myapp.com
ports:
- 80:8080
entrypoint: sh -c /myapp-init-command.sh
volumes:
- /www/host/folder:/var/www/html
As you can see you should decide on which web server rely on.
For example, if you need of apache you should change image to a one which provides ready to use apache, or write a docker file which installs it into a stock ubuntu server like the one provided in my example.
Here an example of this...
docker file
FROM ubuntu:latest
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install apache2 -y
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 8080
CMD ["apachectl", "-D", "FOREGROUND"]
docker compose file
version: "3.5"
services:
nginx:
container_name: my-app
build:
context: .
dockerfile: myapp.dockerfile
hostname: myapp.com
ports:
- 80:8080
volumes:
- /www/host/folder:/var/www/html