I’m new to Docker Compose, and I have successfully created a Docker container hosting a web server. The container is running without any issues. However, I’m facing difficulties displaying an HTML file that should be accessible to my webserver1 in the /usr/local/apache2/htdocs directory inside the container.
When I log into the container using the command sudo docker exec -it webserver1 sh, I can see that the index.html file is present in the mentioned directory. Additionally, I have confirmed that the index.html file also exists in the ./website directory with read and write permissions.
This is my docker-compose.yml
`services:
webserver1:
image: httpd:alpine
container_name: webserver1
restart: always
ports:
- "8081:80"
volumes:
- "./website/:/usr/local/apache2/htdocs"
networks:
- mynetwork
networks:
mynetwork:
driver: bridge
I have tried researching without any luck, so I’m open for suggestions.
I’m expecting to see the index.html file whenever I type in localhost:8081/index.html in my browser, but nothing is displaying.
Cecilie Danbolt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.