Reputation: 71
I have a very simple HTML file which outputs 'Container with HTML file
'.
I have this Dockerfile where I copy my welcome.html
(my simple HTML page):
FROM nginx:latest
WORKDIR /usr/share/nginx/html
COPY welcome.html welcome.html
Then I create an image in the directory containing this HTML page:
docker image build -t html_nginx .
and run a container using:
docker container run -p 80:80 --rm html_nginx
But when the container is run on port 80, I get the default 'Welcome Page
' of nginx and not my desired output from the HTML file ('Container with HTML file
').
How much ever I try, I have never been able to get my message printed on the browser.
Can someone please point me in the right direction?
Upvotes: 7
Views: 22401
Reputation: 1553
First you need to access your container:
docker exec -i -t <container_name> /bin/bash
Now you need to find you index.html file
cd /usr/share/nginx/html
and now, you can change your index.html file with this command
sed -i -e 's/OLD_TEXT/NEW_TEXT/g' index.html
e.g:
sed -i -e 's/nginx!/FELIPE-System/g' index.html
Finish!
Upvotes: 1
Reputation: 5407
The default nginx config will load the index.html
file from the /usr/share/nginx/html
directory.
This default is set in /etc/nginx/conf.d/default.conf
with the lines
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
So to fix this you can copy welcome.html
into the /usr/share/nginx/html
directory as index.html
, or change the above index
line to reference welcome.html
and reload. To make this change more permanent you would likely want to create a dockerfile that defines a docker image overriding the config copied in where you have already set this value.
Alternatively you should just be able to access /welcome.html
when hitting your server e.g. http://localhost:80/welcome.html
Upvotes: 5