docker run throws: No such file or directory - docker

I have image which I try to run with: docker run -p 7111:7111 app/hello/hello:1.0.1-SNAPSHOT but I receive: sh: /app/bin/startApp.sh: No such file or directory. When I check with docker inspect image_id then I can see:
"Entrypoint": [
"sh",
"/app/bin/startApp.sh"
],
Can I somehow get into image and check what exactly is inside?

Related

The mounting a folder to a Docker image remains indefinitely stuck

I'm trying to mount a folder to a docker image in Ubuntu 20.04:
(base) raphy#pc:~$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.tigergraph.com/tigergraph latest 6c55bb15e2a6 7 days ago 10.6GB
hello-world latest feb5d9fea6a5 6 weeks ago 13.3kB
(base) raphy#pc:~$ sudo docker run -t -i -v /home/raphy/ConceptNet/ 6c55bb15e2a6
It doesn't give any error, but it remains indefinitely stuck
Update 1)
(base) raphy#pc:~$ sudo docker run -t -i -v /home/raphy
/ConceptNet:/6c55bb15e2a6/ConceptNet bash
Unable to find image 'bash:latest' locally
latest: Pulling from library/bash
a0d0a0d46f8b: Pull complete
ae2d64a5f3ef: Pull complete
1e5367194cc8: Pull complete
Digest:
sha256:91767623eb341f1717bb37b059e77e8de439c8044064808f6f9bfdc942e8d30c
Status: Downloaded newer image for bash:latest
bash-5.1# ^C
What am I doing wrongly?
SOLVED in this way:
(base) raphy#pc:~$ sudo docker run -d -p 14022:22 -p 9000:9000 -p
14240:14240 --name tigergraph --ulimit nofile=1000000:1000000 -v
~/ConceptNet/:/home/tigergraph/myconceptnet -t
docker.tigergraph.com/tigergraph:latest
https://docs.tigergraph.com/start/get-started/docker#2.-prepare-a-shared-folder-on-host-os-to-be-shared-with-docker-container
Your docker command is insufficient to run tigergraph... it's not a simple run command will do, follow the instruction at https://docs.tigergraph.com/start/get-started/docker
your intention is to bind a local path on your host to your container, but what you are really doing now is attaching a new local empty volume to /home/raphy/ConceptNet/ on your container, just exec:
docker exec {your container id} ls /home/raphy/ConceptNet/
to see the path is created inside your container.
also you can use:
docker inspect {your container id} | less
and check the "Mounts" part to see what volumes you have really attached to your container, the output will be something like:
"Mounts": [
{
"Type": "volume",
"Name": "43f6d9846728547b77666705d2b5a4be1d1e644af80f3bb53d86fe105f57bfc6",
"Source": "/var/lib/docker/volumes/43f6d9846728547b77666705d2b5a4be1d1e644af80f3bb53d86fe105f57bfc6/_data",
"Destination": "/home/raphy/ConceptNet/",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
while
"Name": "43f6d9846728547b77666705d2b5a4be1d1e644af80f3bb53d86fe105f57bfc6"
is the name of the volume you've unintentionally created and attached on path /home/raphy/ConceptNet/ in your container.
if you want to mount a local directory to your container, just use:
sudo docker run -t -i -v /home/raphy/ConceptNet/:/some_path/ 6c55bb15e2a6
and if you want to have shell inside your container its better to include your command at the end of docker run like:
sudo docker run -t -i -v /home/raphy/ConceptNet/:/some_path/ 6c55bb15e2a6 /bin/sh
Try this
-v, --volume=[host-src:]container-dest[:<options>]:
Reference Link

Docker: what is the use of local volumes and some observation about volumes

I have the following docker file
RUN touch /root/testing
VOLUME ["/root"]
after i build and inpect and under config i see
"Volumes": {
"/root": {}
},
after i run /bin/bash and inpect
"Mounts": [
{
"Type": "volume",
"Name": "fc1dc25de37d6d7593a21443cd2bef74a0a6a4e3276b8353199054404665c398",
"Source": "/var/lib/docker/volumes/fc1dc25de37d6d7593a21443cd2bef74a0a6a4e3276b8353199054404665c398/_data",
"Destination": "/root",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
When i start a container it creates a local volume and mount it on /root. It also copies the contents of /root into the local mount
if i do on the host we can see testing file in it
ls /var/lib/docker/volumes/fc1dc25de37d6d7593a21443cd2bef74a0a6a4e3276b8353199054404665c398/_data
testing
But the local volume will be destroyed immediately after the container is killed.
So what is the purpose of local volume. Because sometimes i if by mistake kill the container and still i want to have some data craeted by my container on the local volume, then its not possible since the local volume is also deleted.
I wanted to try named volumes.
I created
docker volume create test
then i my docker file:
RUN touch /root/testing
VOLUME [{"Name":"test","Destination":"/root","external":"true"}]
OR
VOLUME [ "Name:{"Destination":"/root","external":"true"}"]
When i try to build i get:
Error response from daemon: when using JSON array syntax, arrays must be comprised of strings only
Then the only option left out is mount volume from command line rather than Dockerfile
docker run --rm -it --mount source=test,destination=/root archlinux/test /bin/bash
[root#7c7001221c14 /]# ls /root
testing
Now i check the test volume contents:
$ docker run --rm -it --mount source=test,destination=/tmp/myvolume archlinux/base ls /tmp/myvolume
testing
Here since test volume is completely empty so it copied the contents of the /root (i.e file testing) from the image when i do docker run --rm -it --mount source=test,destination=/root archlinux/test /bin/bash into the volume test
But if the test volume is not empty befor i docker run --rm -it --mount source=test,destination=/root archlinux/test /bin/bash: i.e
sudo cd /var/lib/docker/volumes/test/_data
rm -rf *
mkdir hellophp
and then do
docker run --rm -it --mount source=test,destination=/root archlinux/test /bin/bash
[root#7c7001221c14 /]# ls /root
hellophp
So my observations are:
---- VOLUME ["/path/in/container/"] will only create local volumes we cant use named volumes here
---- If i want to use named volumes then
a) create a named volume
docker volume create test
b) mount the named volume into the container path
--mount source=test,destination=/path/in/container
------ *** Most important observation
IF named volume is empty (no files in it) then after runnnig
docker run --rm -it --mount source=test,destination=/path/in/container IMAGENAME CMD
it will copy the contents of /path/in/container to test volume and then mount test volume at /path/in/container
ELSE (i.e named volume has some file in it) then after running
docker run --rm -it --mount source=test,destination=/path/in/container IMAGENAME CMD
It will not change the test volume by copying files from /path/in/container to test volume before mounting.
It will mount test volume at /path/in/container. So any files existing in the /path/in/container will not be available in the container.
If you are running a database in docker you can mount a local directory directly into your container using the -v option on the run command.
docker run -d \
-v <local path>:<container path>:z \
..
..
<your image>
The actual storage will be persistent on your local filesystem, and accessible in the container when the container is running.
Also read this
https://docs.docker.com/storage/volumes/

Docker volume access from host

I have a docker file that looks like this. How can I access this volume from the host? I checked the volumes folder where Docker is installed.
FROM busybox
MAINTAINER Erik Kaareng-sunde <esu#enonic.com>
RUN mkdir -p /enonic-xp/home
RUN adduser -h /enonic-xp/ -H -u 1337 -D -s /bin/sh enonic-xp
RUN chown -R enonic-xp /enonic-xp/
VOLUME /enonic-xp/home
ADD logo.txt /logo.txt
CMD cat /logo.txt
ls
$ docker volume ls
DRIVER VOLUME NAME
local b4e99290fd4d5f7a3fe700ae9b616c2e66b1f758c497662415cdb47905427719
I would like to be able to cd into that volume.
inspect
docker volume inspect b4e99290fd4d5f7a3fe700ae9b616c2e66b1f758c497662415cdb47905427719
[
{
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/b4e99290fd4d5f7a3fe700ae9b616c2e66b1f758c497662415cdb47905427719/_data",
"Name": "b4e99290fd4d5f7a3fe700ae9b616c2e66b1f758c497662415cdb47905427719",
"Options": {},
"Scope": "local"
}
]
After looking at a lot of posts, I finally found a post that address the question asked here.
Getting path and accessing persistent volumes in Docker for Mac
Note: this works only for Mac.
The path for the tty may also be present here:
~/Library/Containers/com.docker.docker/Data/vm/*/tty
Instead of doing it within the dockerfile, you can simply mount with docker run -v /path/in/host:/path/in/container image-name....
Docker volume ls lists all volumes docker volume inspect lets you inspect a volume. If you cant find your volume with docker volume ls try docker inspect your container and check for info there

docker volume mount directory in windows

I'm using docker 1.13.1 in Windows 10 with Hyper-v
and I've a volume
C:\autotestDocker\plat1>docker inspect plat1_logscore
[
{
"Driver": "local",
"Labels": {
"com.docker.compose.project": "plat1",
"com.docker.compose.volume": "logscore"
},
"Mountpoint": "/var/lib/docker/volumes/plat1_logscore/_data",
"Name": "plat1_logscore",
"Options": {},
"Scope": "local"
}
]
Is it possible to found in the filesystem the "Mountpoint" directly?
I cannot change the mount method (I cannot mount it to another folder), I have these settings and I cannot change them...
I've tried with an ubuntu machine and if I try to do
cd /var/lib/docker/volumes/plat1_logscore/_data
I can modify or copy file inside the correct volume.
I would do the same with windows, but I'm just not able to locate the mount directory
You can mount the volume in another container and modify it from there.
docker run -it --rm -v plat1_logscore:/target ubuntu
Select whatever image you'd like to use in place of ubuntu. Then your plat1_logscore volume will be accessible under /target and you can edit it with any commands included inside of your container.
Alternatively, you can copy the files out to your host with a command like:
docker run -it --rm -v plat1_logscore:/source \
-v c:/Users/Marco/plat1_logscore:/target \
busybox cp -avr /source/. /target/.
You can reverse the volumes in the command to copy files back into your named volume from your host.

Error: Cannot Start Container: stat /bin/sh: no such file or directory" [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have been trying to create my own busybox base image.
# ./mkimage.sh -t pensu/busybox busybox-static
+ mkdir -p /var/tmp/docker-mkimage.US3tHy0uBQ/rootfs
+ tar --numeric-owner -caf /var/tmp/docker-mkimage.US3tHy0uBQ/rootfs.tar.xz -C /var/tmp/docker-mkimage.US3tHy0uBQ/rootfs '--transform=s,^./,,' .
+ cat > '/var/tmp/docker-mkimage.US3tHy0uBQ/Dockerfile'
+ rm -rf /var/tmp/docker-mkimage.US3tHy0uBQ/rootfs
+ docker build -t pensu/busybox /var/tmp/docker-mkimage.US3tHy0uBQ
Sending build context to Docker daemon 863.2 kB
Sending build context to Docker daemon
Step 0 : FROM scratch
--->
Step 1 : ADD rootfs.tar.xz /
---> 8eac78bfc9d6
Removing intermediate container ad9bbb8f7536
Successfully built 8eac78bfc9d6
+ rm -rf /var/tmp/docker-mkimage.US3tHy0uBQ
I can see the image is available with my docker repo.
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
pensu/busybox latest 8eac78bfc9d6 7 seconds ago 2.476 MB
But when I try to do docker run, I always get the error:
# docker run -it pensu/busybox /bin/sh
exec: "/bin/sh": stat /bin/sh: no such file or directorytime="2015-04-09T16:03:45+05:30" level="fatal" msg="Error response from daemon: Cannot start container 8fe73b7832193c847d7975175a4be86d1f0b550b6a00b812bd4cdd18fe752468: exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
I am not able to understand why is it giving that error? Am I doing something wrong? How else can I validate that I am creating a correct image that is in working condition?
After you create image, check it with:
$ docker inspect $image_name
and check what you have in CMD option. For busy box it should be:
"Cmd": [
"/bin/sh"
]
Maybe you are overwritting CMD option in your ./mkimage.sh
I hit this error ("stat /bin/bash: no such file or directory") when running the command:
docker exec -it 80372bc2c41e /bin/bash
The solution was to identify the kind of terminal (or shell) that is available on the container. To do so, I ran:
docker inspect 80372bc2c41e
In the output from that command, I saw:
"Cmd": [
"/bin/sh",
"-c",
"gunicorn -b 0.0.0.0:7082 server.app:app"
],
This tells me that there's a /bin/sh command available, and I was able to connect with:
docker exec -it 80372bc2c41e /bin/sh
Using $ docker inspect [imageID] Incase the Image has no /bin/bash in the output, you can use command below: it worked for me perfectly
$ docker exec -it <container id> sh
This error
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec:
\"/bin/sh\": stat /bin/sh: no such file or directory": unknown.
occurs when creating a docker image from base image eg. scratch. This is because the resulting image does not have a shell to execute the image. If your use:
ENV EXECUTABLE hello
cmd [$EXECUTABLE]
in your docker file, docker uses /bin/sh to parse the input string. and hence the error. Inspecting on the image, your will find:
$docker inspect <image-name>
"Entrypoint": [
"/bin/sh",
"-c",
"[$HM_APP]"
]
This means that the ENTRYPOINT or CMD arguments will be parsed using /bin/sh -c. The solution that worked for me is to parse the command as a JSON array of string e.g.
cmd ["hello"]
and inspecting the image again:
"Entrypoint": [
"hello"
]
This removes the dependence on /bin/sh the docker app can now execute the binary file. Example:
FROM scratch
# Environmental variables
# Copy files
ADD . /
# Home dir
WORKDIR /bin
EXPOSE 8083
ENTRYPOINT ["hospitalms"]
Hope this helps someone in future.
On Windows (msys) using Docker Toolbox/Machine, I had to add an extra / before /bin/bash to indicate that it was a *nix filepath.
So,
docker run --rm -it <image>:latest //bin/bash
check your image cmd using the command docker inspect image_name . The output might be like this:
"Cmd": [
"/bin/bash",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\"]"
],
So use the command docker exec -it container_id /bin/bash. If your cmd output is different like this:
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/sh\"]"
],
Use /bin/sh instead of /bin/bash in the command above.
Explicitly mention the ubuntu version in the docker file which you are trying to RUN,
FROM ubuntu:14.04
Dont use like FROM ubuntu:Latest. This resolved my above "Cannot Start Container: stat /bin/sh: no such file or directory" issue
I had a similar problem:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"sh\": executable file not found in $PATH": unknown.
In my case, I know the image works in other places, then was a corrupted local image.
I solved the issue removing the image (docker rmi <imagename>) and pulling it again(docker pull <imagename>).
I did a docker system prune too, but I think it's not mandatory.

Resources