Docker Symlinks Not Woking On Fresh Install - docker

I am a complete noob to Docker, I apologize if this a simple question, I seem to have a significant installation/configuration error in Docker. I am working on a fresh install of Ubuntu 20.04 and Docker version 20.10.12, build e91ed57.
I am literally trying to follow the basic Docker tutorial for beginners from their website and the second command is not working.
The tutorial is no big deal, I can switch tutorials to something more up to date, but it seems that key functionality of Docker is not working correctly.. symlinks.
This command docker build -t getting-started . results in this error:
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/<user>/Downloads/WebDev/Docker/tutorial/getting-started-master/app/Dockerfile: no such file or directory
I double & triple checked everything. I literally tried every solution found here:
Docker: unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx
Docker build gives "unable to prepare context: context must be a directory: /Users/tempUser/git/docker/Dockerfile"
Nothing worked. I could only execute the command using an explicit path. rather than "." which is going to get annoying pretty quickly when developing real projects.
docker build -t getting-started ~/Downloads/WebDev/Docker/tutorial/getting-started-master/
All documentation states docker build -t getting-started . is the correct command, so I am worried about continuing with a "broken" docker installation.
I ran the docker ./check-config.sh script and it shows all is well except CONFIG_RT_GROUP_SCHED: missing which I thought was inconsequential for the moment since hello-world image worked as expected.
Hhhmmm?

What directory are you in when running these commands? From your error it seems you are in the /app directory, whilst you should probably be 1 directory up.
Or, alternatively, your dockerfile is 1 directory below where it was intended to be. I draw this conclusion by comparing the 2 paths you mention:
~/Downloads/WebDev/Docker/tutorial/getting-started-master/app/Dockerfile
vs
~/Downloads/WebDev/Docker/tutorial/getting-started-master/
If the second one works, then the dockerfile is under getting-started-master and not under /app.
Fyi: Docker has a context and unless you explicitly specify it to be something different, by default it's going to be the directory the Dockerfile is located in.

Related

Cant create image/ the Dockerfile (Dockerfile) cannot be empty

I am taking a beginner course and not able to create an image on terminal.
Here is the course I am taking(Sorry, the course is in Japanese course but just for the reference). I am at 1:01:39 where he proceeds to create docker image.
First, the error message contained Failed to solve with frontend docker file.v0:failed to create LLB definition:the Dockerfile cannot be empty
I ran below command and managed to get rid of Failed to solve with frontend docker file.v0:failed to create LLB definition (Failed To Resolve With FrontEnd DockerFIle.v0):
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
Now I'm left with the Dockerfile cannot be empty
I saw in some page that people fail to locate because of not capitalized dockerfile but that's not my case.
I have also tried -f on the command to direct file
I saw that you, don't save your dockerfile, try save changes and run docker build again.
Also saw same issue on github, it could be helpful
Try to change COPY to ADD
https://github.com/docker/compose/issues/5170

docker build question no permission to read from

I'm trying to build a docker image
I get this error
sudo docker build . -t django-demo
error checking context: 'no permission to read from '/home/benny/.ICEauthority''
any ideas why this is happening?
--------------------------
ubuntu 18.04
Docker version 18.09.9
Create a new directory, place your Dockerfile in this new directory and then run your sudo docker build . -t django-demo command from that directory. This should solve your problem. Found related problems and solution in this external thread.
Generally to solve this kind of problem you should add a .dockerignore file in which you list all the files you don't want to be sent to the build's context (ie. the files that docker don't need to build your image).
In your case simply creating a .dockerignore with the following content should solve the issue :
.ICEauthority
Note that specifically in your case though, you should not run your docker build command directly from your home directory, because all the content of your home is being sent to the build's context (which is heavy, might make you run out of disk space or generate permission issues).

NodeMCU Build in Docker results in "exec format error"

I'm trying the NodeMCU Docker build in Ubuntu 16.04.4 LTS for the first time.
I have read the tagged articles here for Docker and NodeMCU, but don't see this particular error.
"docker run hello-world" has no problems.
I have tried the NodeMCU build command in both forms:
$ docker run --rm -ti -v `pwd`:/opt/nodemcu-firmware marcelstoer/nodemcu-build
and the explicit path variation:
$ docker run --rm -it -v /home/tim/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build
In both cases, I get this error:
standard_init_linux.go:187: exec user process caused "exec format error"
I have searched on this error, and most solutions are related to a missing shebang.
However, I'm not sure what script would need the shebang, or why it would be not working in my case but correct for others.
Has anyone else run across this error?
Speaking without deep technical details, this error means that the kernel can not recognize the format of the executable file, thus, it can not run this file. In your case this error is about the executable file which is started when the container is launched. According to the Cmd entry in the output of docker inspect marcelstoer/nodemcu-build, it is a file /bin/sh, which is an ELF executable.
When Linux can not execute ELF binary and returns such an error (about the file format), it usually is related to the system architecture. More specifically, the image marcelstoer/nodemcu-build contains ELF64 executables (i.e. for amd64 architecture), and your system does not support it (is it i386 or even some flavor of arm?). Running docker run hello-world, however, works fine for you, because hello-world image exists for all architectures supported by Docker.
According to the Dockerfile of marcelstoer/nodemcu-build image, it is built from ubuntu, which exists for different architectures, thus, you may try building the marcelstoer/nodemcu-build image on your system rather than pulling it from the dockerhub.
P.S.: regarding the solution you have linked to your question. This is not about your case (ELF binary), rather it is about a script. In case of script, the executable format is recognized by the shebang (#!) at the very beginning of the file, thus, the script must start with #!, not with the newline. That's why the author got the same error: the kernel could not detect that this is a script and failed to start it. Different (but similar) reasons, same error.

Docker Copy seems buggy

So I am trying to make a simple docker container to run sabnzbd in a container.
I do a git clone and then move sabnzbd folder into container.
Note: When I look in sabnzbd, all files look ok so it's not a git problem or branch etc. I'm happy so far there.
When I then run the container, I double checked but half the files are missing. For example, I was looking to make sure cheerypy was copied but it wasn't, and yes, i can confirm that I double checked again in sabnzbd folder.
So I have a folder with Dockerfile and sabnzbd. I built from that folder with the command:
sudo docker build --no-cache=true -t sabnzbd -f Dockerfile .
In a nutshell, the only thing that worked was Copy . /
I tried COPY sabnzbd/* sabnzbd and other variations.
I originally thought it was getting files from elsewhere but removed any trace of sabnzbd, but for my understanding it only looks at files relative to the docker build file.
I just thought this was so soo weird and wanted to get some thoughts even though I fixed it. I did remove all images and started from scratch but result was the same.
I did try the no cache option with build but still the same.
Thoughts?

building go package using docker

I am trying to dockerize the go package that I found here...
https://github.com/siddontang/go-mysql-elasticsearch
The docker image is much more convenient than installing go on all the servers. But the following dockerfile is not working.
FROM golang:1.6-onbuild
RUN go get github.com/siddontang/go-mysql-elasticsearch
RUN cd $GOPATH/src/github.com/siddontang/go-mysql-elasticsearch
RUN make
RUN ./bin/go-mysql-elasticsearch -config=./etc/river.toml
How do I build a go package directly from github using a concise dockerfile?
Update
https://hub.docker.com/r/eaglechen/go-mysql-elasticsearch/
I found the exact dockerfile that would do this. But the docker command mentioned on that page does not work. It does not start the go package nor does it start the container.
It depends on what you mean by "not working", but RUN ./bin/... means RUN from the current working directory (/go/src/app in golang/1.6/onbuild/Dockerfile).
And go build in Makefile would put the binary in
$GOPATH/src/github.com/siddontang/go-mysql-elasticsearch/bin/...
So you need to add to your Dockerfile:
WORKDIR $GOPATH/src/github.com/siddontang/go-mysql-elasticsearch
I guess this should do what I am looking for.
https://github.com/EagleChen/docker_go_mysql_elasticsearch
And I hope one day I will learn to use that little search box.

Resources