Hi I have a an issue when I try to build a nginx server by using the commands within the following Dockerfile. I get an error which is failed to compute cache key: "/ADD" not found: not found. It happens when I try to uncompress the tar file with the ADD command. I run the build command docker build --tag local:dockerfile-example . . How would I be able to fix this?
Since that problem was solved I encountered another one, if you could help with that also I would appreciate ıt:
So after the image is build by executing the command docker build --tag local:dockerfile-example . I try to run the docker container with the following command docker container run -d --name dockerfile-example -p 8080:80 local:dockerfile-example. I check the status of the container with docker ps and it is not visible although when I run docker ps -a. I see the container information I see that the port alignment is not visible 8080:80. I am running on macSO Montrey. Would you know how I can fix this issue?
output for running docker ps -a :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a4002581729 local:dockerfile-example "/bin/sh -c [“nginx”…" 20 seconds ago Exited (127) 19 seconds ago dockerfile-example
The doube quotes look off. Your LABEL instructions use correct double quotes, while your ENTRYPOINT and CMD does not. You might want to fix that and try again.
hmm, doesn’t realy make sense, as nginx is installed as alpine package and should be in the path.
Just out of curiousit: have you considered to use the official nginx image as base image? It has tags for an alpine flavor and has a rather nice entrypoint script that allows to add custom scripts and even provides a simple templating engine.
update: I am afraid something is off with the encoding of these lines:
I copy/pasted your Dockerfile content into a file using vi and this is what I see. please type those lines again in an editor like vscode or an ide like intellij.
Oh I am new docker and linux images in general. I was using a dockerfile that was created from this tutorial book that I was using. I could possibly try that but I will have to sort the dockerfile image and learn about it.
I have changed the code on vscode and tried it when I told you it wasnt working, my changes are as follows:
ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]
P.S sorry for all the trouble, and thanks for the helping hand.
I created a Dockerfile with your content, commented out the COPY and ADD instructions as I don’t have the files, build the image, started a container from the image: it works.
Note: since the logs are written into the container filesystem, docker logs will not show any logs for the nginx process itself. You might want to check the Dockerfile of the official nginx image, to see how they solved it (see lines 107 to 109).
I don’t know it still doesn’t work, my guess is that it is either with the contents of the files I copied and added or since the book I’m learning from used the latest alpine image from a couple years ago then mine might be creating the issue because of updates on the alpine image over the years. Regardless thanks for the help.
If you would like to replicate the whole setup I will leave the contents of default.conf , nginx.conf in here:
When the container doesn’t work even after you tried recommended fixes, please, always share your error message again even if you think that is the same. If you just didn’t notice the difference, we can spend hours on something that does not even exist.
I have the same problem and I can’t integrate a file with DockerFIles. I Replace :
- kind: RUN
value: wget https://github.com/xxxx.onnx
by :
- kind: COPY
value: P0005.onnx .
and I have :
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref e08f4118-2d93-490f-8733-5c2e2d5a57f6::nrcq5r7dyoom7dvk8zucy7os3: "/P0005.onnx": not found
And P0005.onnx is in the same directory of my DockerFIles, any Idea ?