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.
Related
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.
I am trying to develop a project locally using Docker Compose and to prevent re-building my image on every update, I've added a bind-mount that maps my src directory to my WORDIR in Docker. All changes made on my local machine are then reflected in my Docker container...EXCEPT for one file. For some reason, there's a single file in my project, that when I change its contents, the change is not reflected in the Docker container even though other files adjacent to this file DO detect file changes. Which leads me to believe that the directory is mapped correctly but it's some other issue with the file itself?
docker-compose.yaml
graphql:
build:
context: .
dockerfile: ./app/graphql/src/Dockerfile
target: development
volumes:
- ./app/graphql/src:/workspace
- /workspace/node_modules/
Dockerfile
# ------------> Base Image
FROM node:14 AS base
WORKDIR /workspace
COPY ./app/graphql/src .
# ------------> Development Image
FROM base AS development
CMD ["npm", "run", "dev"]
I haven't figured out how to show directory structure but the files that I am modifying are located in:
/app/graphql/src/api/graphql
Where file a.ts detects changes and is reflected in the Docker container but b.ts does not. I read about how Docker depends on the inode of the file to match if bind mounting specific files. I'm mounting a directory, but for a sanity check, I ran:
ls -i
in both the host and container and confirmed that the inodes matched.
I have two M1 Mac computers and I confirmed that this is a problem between both machines.
Any additional thoughts to debug this problem? My only other thought is that I hit a max number of files that can be tracked, but that's why I removed the node_modules. Any assistance would be really helpful!
EDIT: I created a new file, c.ts and duplicated the contents of b.ts (the file that wasn't changing between host and container)...and c.ts detects changes properly! Is there a way to inspect why a certain file isn't broadcasting changes? This is so strange.
You should remove COPY ./app/graphql/src . directive from your Dockerfile because this folder will mounted to container as volume.
I'm trying to deploy a Nextcloud container, where the config is copied from the local directory to the container. I'm not getting any error when building or running the container, and I can see the steps are successfully executed per the terminal. Regardless, the copied file simply is not in the container. What's going on here?
Dockerfile:
FROM nextcloud:latest
# Copy local config
COPY ./config.php /var/www/html/config
All the evidence:
Thanks!
The file is copied but is being deleted later.
This is a very typical scenario, and in this cases, the best you can do is to see what happens in the parent image nextcloud:latest once the container starts.
In nextcloud's Dockerfile you can see
ENTRYPOINT ["/entrypoint.sh"]
if we open entrypoint.sh in the line 100 you can see clearly that the content of /var/www/html/config is modified
You can maybe do any of these options
Copy the file to a different temporary location, and create your own entrypoint (you can copy-paste from the original one to hit the ground running, or you can try to figure out a fancier solution)
Or also you can copy the file after creating and running the container
docker cp config.php copytest:/var/www/html/config
I am trying to change some configuration files required for application setup but do not want to change the original config file in the source code.
The path to the original config file is /usr/src/app/env_configs/local_db_setup.rb
The way I try to achieve this is in my Dockerfile
cp <path of new config on host>/local_db_setup.rb /usr/src/app/env_configs/
However, I perceive that due to my volume mounted in docker-compose.yml, the Copy is not taking place or overridden.
volumes:
-.:/usr/src/app
How can I go about this?
If you bind-mount into a non-empty directory on the container, the directory’s existing contents are obscured by the bind mount. So any existing contents at /usr/src/app inside the container are shadowed.
If you want to copy the new config file during image build time as mentioned in your question, you can copy it to a different directory in the image(/tmp/config/) and move it to correct location (/usr/src/app/env_configs/) using an entrypoint script which does the move first and then starts the actual entrypoint.
Instead you can also directly mount the config file from host machine if that is okay.
I'm new to Docker and Dockerfile, still learning a lot of. But I have a question quite simple but still didn't find the answer for that.
I'm following several tutorials, more specifically the ones at Katakoda.
The command (on Dockerfile) COPY. /usr/share/nginx/htmlis said to
copies the content of the current directory into a particular location
inside the container.
But this includes the Dockerfile itself? I'm just curious.
Yes.
COPY . /usr/share/nginx/html
Above statement in Dockerfile will copy all the contents in your current directory on the docker host to /usr/share/nginx/html inside docker container.
You can use .dockerignore if you want anything to be ignored by docker while copying etc.
In case you just want static files to be copied, put them in a different directory and use it in Dockerfile -
COPY ./app /usr/share/nginx/html