I can't see my html when I built container with docker - docker

I have my container running like this
in the file directory C:\Users\hailey\Desktop\GitTest Where my project file are.
# getting bse image nginx
FROM nginx
MAINTAINER hailey
COPY . /usr/share/nginx/html
This is my docker file and I want to run my html file, which located in C:\Users\hailey\Desktop\GitTest
When I accessed to http://127.0.0.1:8080/
I see only this page, which is not helloWorld.html

you can copy and replace testhelloWorld.html with index.html
COPY testhelloWorld.html /usr/share/nginx/html/index.html

Related

Dive into the Dockerfile of nginx parent image

I am trying to understand the Dockerfile of nginx official Docker image. I am focusing on the following lines:
COPY docker-entrypoint.sh /
COPY 10-listen-on-ipv6-by-default.sh /docker-entrypoint.d
I am playing locally with Docker Desktop. If my Dockerfile has only the following line:
FROM nginx
and building my own nginx image, then what is the build context for the Dockerfile of nginx Docker image? My issue is I cannot understand where the files:
docker-entrypoint.sh
10-listen-on-ipv6-by-default.sh
are living and where are they copied from?
Same question is applied to Ubuntu image
The build context is always the directory you give to the build command, and it usually contains the Dockerfile directly in that directory.
docker build ./build-context-directory
# Docker Compose syntax
build: ./build-context-directory
build:
context: ./build-context-directory
The two important things about the context directory are that it is transferred to the Docker daemon as the first step of the build process, and you can never COPY or ADD anything outside the context directory into the image (excepting ADD's ability to download URLs).
When your Dockerfile starts with a FROM line
FROM nginx
Docker includes a pre-built binary copy of that image as the base of your image. It does not repeat the steps in the original Dockerfile, and you do not need the build-context directory of that image to build a new image based on it.
So a typical Nginx-based image hosting only static files might look like
FROM nginx
COPY index.html /usr/share/nginx/html
COPY static/ /usr/share/nginx/html/static/
# Get EXPOSE, ENTRYPOINT, CMD from base image; no need to repeat them
which you can run with only your application's HTML content but not any of the Nginx-specific details you quote in the question.

docker-compose is not copying new config file

I had default file in docker/nginx.conf I edited it, but when I log into Docker image, there is unedited default config file. I don't know why Docker wont copy this specific file with actuall version and copy default one, but others are in the container properly showing.
Here is my Dockerfile where I copy files
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
COPY configuration/gunicorn_config.py /etc/netbox/config/
COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
COPY startup_scripts/ /opt/netbox/startup_scripts/
COPY initializers/ /opt/netbox/initializers/
COPY configuration/configuration.py /etc/netbox/config/configuration.py
I am using Dockerfile from netbox-docker image from here:
https://github.com/netbox-community/netbox-docker/blob/release/docker-compose.yml
And also docker-compose from same image as above:
https://github.com/netbox-community/netbox-docker/blob/release/Dockerfile
There is need to rebuild image, but I can also acces volumes via /var/lib/docker/volumes/ and that solves my problem before building.

docker COPY is not copying the files

FROM nginx:alpine
EXPOSE 80
COPY . /usr/share/nginx/html
Am trying to run an Angular app with the following docker configuration. It does work, but I can't see the files/directory that was suppose to be copied in that location "/usr/share/nginx/html" which is super confusing. The directory only contains the default index.html nginx created.
Does it store it in memory or something since the files are not there but it does fetch my website properly.
Build:
docker build -t appname .
Run:
docker run -d -p 80:80 appname
It seems like the COPY destination path is not the path on disk server but its the path inside the image of the docker. Which explains why i cant see my files on the server disk.

How to deal with custom nginx.conf files in Amazon ECS?

I basically have two docker images: nginx image and a php image, that I want to upload to ECS. Both are run by a docker-compose.
The nginx has a myapp.conf file that I want to copy from somewhere into the container's /etc/nginx/conf.d folder.
Whats the best way to deal with this?
Prepare your own nginx image and use the COPY command.
FROM nginx
COPY myapp.conf /etc/nginx/conf.d
Build it:
docker build -t mynginximg .
and use it in your compose files.

Docker copy files to and mount same folder

I am working on 'tomcat:7.0.75-jre8-alpine' base image and want to deploy my web application alongwith its configurations file. Below is what I am doing in Dockerfile:
......
COPY <my-app-configurations> /org/app/data
COPY <my-app-configurations> /org/app/conf
......
CMD ["catalina.sh", "run"]
And I am using below command to create a container from above image:
$ docker run -p 8080:8080 -v "/c/Users/jaffy/app:/org/app" myapp-image
'/c/Users/jaffy/app' folder is initially empty and I want to get all contents of '/org/app' in it and remains in-sync.
Initially, all configurations are copied in '/org/app' folder but when '/c/Users/jaffy/app' is mounted, '/org/app' gets cleaned/emptied.
How can I solve this issue that host machine folder remains empty initially but afterwards it reflects the exact state of container's '/org/app' folder and its sub-directories.
Thanks a lot in advance.
There is no way to keep the container's folder content when you mount/share a volume over that folder, because the command is replacing the folder not merging it.
If you don't need to replace all the files in the folder you could just mount the file that need to be changed like:
$ docker run -p 8080:8080 -v "/c/Users/jaffy/app/web.xml:/org/app/web.xml" my-app-image

Resources