nginx : executable file not found in $PATH": unknown - docker

I am trying to deploy the Nginx image using the Redhat UBI image as I build the image which compiles without errors. I get error executable file not found in $PATH": unknown.
Could anyone please tell me what I am missing in my dockerfile?
I am using the image from RedHat UBI open images, using the container images that have been provided.
https://catalog.redhat.com/software/containers/search?q=ubi
Below is my Dockerfile that I am using.
FROM registry.access.redhat.com/ubi8/ubi-init
USER root
COPY api-gatway /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
Below is the error I get after trying to run the docker image
docker run --name testinxcg -d -p 8080:80 test
6220f7274745212afbab07e20bbbf9fa4995a834962b104d7951b6d4965a3237
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"nginx\": executable file not found in $PATH": unknown.
uk-c02xk2ykjg5j:api-gateway mbyousaf$

There's no docker in Red Hat Enterprise Linux (RHEL) 8, but an OCI-compatible alternatives called Podman and Buildah.
To enable container management without the need for daemons, Red Hat has introduced a set of tools for your Linux container application development:
Buildah allows you to build a container without any daemon or docker.
Podman allows you to manage containers without the daemon dependency it’s also docker cli compatible.
# podman pull
RHEL 8 compatible images can be found [here][2].
# yum install -y podman
# alias docker=podman
type to use podman in place of docker - for using docker commands

Related

How to run a private Docker image

docker run -i -t testing bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown.
I created the image in Docker Hub , it is private image.
FROM scratch
# Set the working directory to /app
WORKDIR Desktop
ADD . /Dockerfile
RUN ./Dockerfile
EXPOSE 8085
ENV NAME testing
This is in my Dockerfile
I tired to run it, when i run docker images i am getting the details
I think you need to do login in command prompt.useing below command.
docker login -u username -p password url
Apart from the login which should not cause these, as you build an image on your local system which I assume it should exist on local system which will only pull image if not exist on local, the real reason is you are building an image from scratch and there are no binaries in scratch image, even no bash or sh.
Second mistake:
RUN ./Dockerfile
Your Dockerfile is a file, not binaries, while here you are trying to execute using RUN directive.
While scratch appears in Docker’s repository on the hub, you can’t
pull it, run it, or tag any image with the name scratch. Instead, you
can refer to it in your Dockerfile. For example, to create a minimal
container using scratch:
FROM scratch
COPY hello /
CMD ["/hello"]
While here hello can be an executable file such as a C++ compiled file.
Docker scratch image
But what I would suggest to say "hello" in Docker is to use Busybox or Alpine as a base image which has a shell and both are under 5MB.
FROM busybox
CMD ["echo","hello Docker!"]
now build and run
docker build -t hello-docker .
docker run --rm -it hello-docker

Cannot mount a folder with Docker

I can't get the -v option to work with Docker. My host is Linux Mint and my image is using Ubuntu:latest.
sudo docker run -it opencv:latest -v /home/rr/Desktop/mytest:/src
It gives the error
docker: Error response from daemon: OCI runtime create failed:
container_linux.go.345: starting container process caused
"exec: \"-v\": executable file not found in $PATH": unknown.
I have tried different things. Both mounting to a folder in the image that exists and one that does not, but it is the same error either way.
The usage of docker run is:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
So your options need to go before the image name, including the -v option. If you put it after the image name, it sees it as the command to run instead of an option. Try:
sudo docker run -it -v /home/rr/Desktop/mytest:/src opencv:latest

docker image build failing;operating system is not supported

I am following 'kubernetes-for-java-developers' Arun gupta's tutorial for learning docker/kubernetes.
https://github.com/arun-gupta/kubernetes-for-java-developers
I am failing in this particular step
docker image build --file Dockerfile.jre -t arungupta/greeting:jre-slim .
while I am using docker desktop, windows container, getting below messege.
F:\Work\Workspace\IntellejIdea\kubernetes-for-java-developers\app>docker
image build --file Dockerfile.jre -t arungupta/greeting:jre-slim .
Sending build context to Docker daemon 219.5MB
Step 1/7 : FROM debian:9-slim
operating system is not supported
while I am using docker desktop, linux container, getting below messege on running below command
docker container run -d -p 8090:8080 arungupta/greeting:jre-slim
F:\Work\Workspace\IntellejIdea\kubernetes-for-java-developers\app>docker container run -d -p 8090:8080 arungupta/greeting:jre-slim
db92a3cc25635d1d2a7f02cd7c94dd11af6b17ea5b258dcaf740de93a05221f7
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"./myjre/bin/java\": stat ./myjre/bin/java: no such file
or directory": unknown.
My operating system is windows 10 pro.
Dockerfile.jre
FROM debian:9-slim
COPY target/app.war /root
COPY myjre /root/myjre
EXPOSE 8080 5005
WORKDIR /root
ENV _JAVA_OPTIONS '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
CMD ["./myjre/bin/java", "-jar", "app.war"]
As I am new on this docker/kubernetes technology, not sure where to start debugging, or the issues.
help appreciated!!

Building docker image causing "stat /bin/sh: no such file or directory" on CentOS while working on Ubuntu

I have a Dockerfile which works (build and run) on Ubuntu 18.04. Now, I have to build it on a CentOS 7 machine where I have very limited rights.
My dockerfile looks like this:
FROM ubuntu:18.04
RUN apt-get update
ENTRYPOINT echo "Hello world"
When I try to build via docker build -t foo . (while being in the directory with the Dockerfile) I'll get
Sending build context to Docker daemon 2.048 kB
Step 1/3 : FROM ubuntu:18.04
---> 20bb25d32758
Step 2/3 : RUN apt-get update
---> Running in dcb3efe30efb
container_linux.go:247: starting container process caused "exec:
\"/bin/sh\": stat /bin/sh: no such file or directory"
oci runtime error: container_linux.go:247: starting container process
caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
See also screenshot
All I find on Google is about Entrypoint etc, but my problem is obviously there before I even get to the Entrypoint.
On the CentOS 7 host, there is definitely /bin/sh. I can execute a Shell script foo.sh by running the command /bin/sh foo.sh without any trouble.
Leaving this here after messing around multiple hours with the same issue:
The issue in my case was with a corrupt image. It was very stubborn to disappear :)
So try with docker system prune -a, restart docker and build again.
Note that this removes all your images and containers, which can not be undone.
For more see: docker system prune

Cannot run FreeBSD terminal in docker container

I am using a FreeBSD image from dockerhub. After pulling the image, I need to run a container with a terminal to test some commands inside the container.
I am trying this command:
sudo docker run --rm -it auchida/freebsd ./bin/bash
And I get the error:
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec:
\"./bin/bash\": stat ./bin/bash: no such file or directory": unknown
Could anyone help me ?
There is no bash binary embedded in the image, located at /bin/bash or everywhere else : you can check it by looking at base.txz contents.
You can use /bin/sh instead (the default shell, take a look at the Dockerfile) :
sudo docker run --rm -it auchida/freebsd /bin/sh
(/bin/sh is optional in the previous command, since it is the default CMD).
If you really want bash, you must install it.
Note also that you must be on a FreeBSD host to be able to run a container with this image.

Resources