0

I want to create my own Docker image using the following Dockerfile

FROM scratch
COPY apache-cassandra-3.11.6-bin.tar.gz .
RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz 

When I run the command, the tar instruction fails. Why? I am on Windows 10.

C:\Users\manuc\Documents\manu\cassandra_image_test>docker build -f CassandraImageDockerFile.txt -t manucassandra .
Sending build context to Docker daemon  184.8MB
Step 1/3 : FROM scratch
 --->
Step 2/3 : COPY apache-cassandra-3.11.6-bin.tar.gz .
 ---> Using cache
 ---> deda426d6948
Step 3/3 : RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz .
 ---> Running in 3edfb1031c06
OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown

Could it be that because I am not using an existing image, tar is not present in the image and thus tar is failing?

Manu Chadha
  • 15,555
  • 19
  • 91
  • 184
  • Looks like already answered question in https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile and https://stackoverflow.com/questions/54820846/starting-container-process-caused-exec-bin-sh-stat-bin-sh-no-such-file – storenth Jun 28 '20 at 13:53
  • Does this answer your question? [Starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown](https://stackoverflow.com/questions/54820846/starting-container-process-caused-exec-bin-sh-stat-bin-sh-no-such-file) – storenth Jun 28 '20 at 13:54

3 Answers3

2
stat /bin/sh: no such file or directory

You started from a scratch image that has nothing. Then you told Docker to RUN a command, but you have no shell.

So you can't run any command, much less tar.

Why not start with alpine?

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
0

It looks like, whatever base image "scratch" is, it doesn't have /bin/sh, let alone tar or anything else. I would consider starting from a known OS image, or even the Cassandra official image on DockerHub. https://hub.docker.com/_/cassandra

Steve
  • 26
  • 1
  • 1
  • 4
0

A Dockerfile that starts FROM scratch starts from a base image that has absolutely nothing at all in it. It is totally empty. There is not a set of base tools or libraries or anything else.

Osamazx
  • 471
  • 1
  • 5
  • 12