'docker' is not recognized as an internal or external command, operable program or batch file - docker

I am trying to build docker images with Jenkins java application, but I getting the following error while after starting the job in Jenkins..
Commands used in Build Step inside Jenkins:
cd JenkinsWithSonar_SB
mvn clean install
docker build -f Dockerfile -t springboot-sonar-docker .
The error message is:
'docker' is not recognized as an internal or external command,
operable program or batch file.

Related

standard_init_linux.go:219: exec user process caused: no such file or directory on Raspbian

Problem: I am attempting to create and run a Docker container of an Edge Service on a Raspberry Pi using 64 bit Raspbian. Due to other limitations, I am attempting to containerize the program (in Golang) by containerizing the build executable file, rather than building the .go in the Dockerfile.
My Dockerfile looks like this
FROM golang:alpine
WORKDIR /build
ADD server .
EXPOSE 50051
CMD ["./server"]
Running the built executable on it's own works correctly, and when creating the Docker Image using the command "sudo docker build -t server:v7 .", the Docker Daemon gives no errors, with the finished image being displayed on the list of Docker Images as if it were correctly working. However, when I try to run the Image, I receive the error "standard_init_linux.go:219: exec user process caused: no such file or directory", rather than the file running.
Some additional notes as per the comments: All of the programs were written in Ubuntu, they were built to an executable on Raspberry Pi, and the Dockerfile was also written on the the Raspberry Pi. When using the command "sudo docker run -it -d : sh", the image will run, and when using the command "sudo docker exec -it sh", terminal will enter the shell. Attempts to run the program from within the shell similarly fail, yielding the error "sh: error not found"
ldd yields the following results:
/lib/ld-linux-aarch64.so.1 (0x7f8731f000)
libpthread.so.0 => /lib/ld-linux-aarch64.so.1 (0x7f8731f000)
libc.so.6 => /lib/ld-linux-aarch64.so.1 (0x7f8731f000)
And there seems to be no problem with Alpine or with $PATH
Do you build on Raspberry or a different machine? If you build on PC, you need to set the build target architecture to match the Raspberry.
The image "golang:alpine" is available for Raspberry, so this should not be the problem.
The error "user process caused: no such file or directory" is then probably related to the file you are trying to execute.
Make sure the file exists in the directory
Make sure the file is executable
Maybe change the CMD to "ls -la" to see in the docker logs if the file is there and which attributes it has.

'livingdoc' is not recognized as an internal or external command, operable program or batch file

I have already run dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI to install specflow livingdoc.
then I run the command below:
But when I run livingdoc test-assembly SpecFlowDemo.dll -t TestExecution.json, I got this error 'livingdoc' is not recognized as an internal or external command, operable program or batch file.
and when I again dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI, it shows below:
Solved already after I run cmd as administrator.
After running
dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
Close and reopen the command prompt before running
livingdoc test-assembly SpecFlowDemo.dll -t TestExecution.json

Getting error - 'build.xml does not exist' when building docker file which contains docker commands to run ant targets

I am creating a docker file to run an ant target which is written in build.xml
My docker file contains below lines.
FROM frekele/ant:1.10.1-jdk8
RUN ant -f ./build.xml all
Then, I am building docker file from command prompt as below,
D:\Support\containarization\cont-new-withfuncactinput\workspace\bas\source\bas\framework\cn\connect_framework> docker build -f ./Dockerfile ./connect-build -t test/connect-build
My build.xml and docker file both are located in same above location.
File Structure,
D:\Support\containarization\cont-new-withfuncactinput\workspace\bas\source\bas\framework\cn\connect_framework
- Dockerfile
- build.xml
But, I am getting below error when building docker
Buildfile: ./build.xml does not exist!
How can I solve this.
You need to push the file to your image before running ant else it does not exist there. You have to use COPY for this
Try to modify your Docker file like the following and it should fix your current problem:
FROM frekele/ant:1.10.1-jdk8
COPY build.xml ./build.xml
RUN ant -f ./build.xml all

docker build error on Synology NAS fails with "Please give the Ant Media Server zip file as parameter..."

I'm trying to build ant media server using Docker CLI on my Synology RS814+ using the instructions here.
Here are my steps:
I've set up a folder called antsms here /volume1/docker/
Created the
dockerfile in that folder
Downloaded the zip file and saved it in
that folder too as
ant-media-server-community-1.8.1-20190828_0800.zip
Logged in as root
and run docker build --network=host -t ams:1.8.1 . --build-arg
AntMediaServer=ant-media-server-community-1.8.1-20190828_0800.zip
It nearly goes all the way through creating a temporary container with a random name before exiting with the following error code.
Please give the Ant Media Server zip file as parameter
./install_ant-media-server.sh ant-media-server-....zip
The command '/bin/sh -c cd home && pwd && ./install_ant-media-server.sh ${AntMediaServer}' returned a non-zero code: 1
I had to add the . after the name tag otherwise docker build would not run but that is not in the instructions. Docker daemon on NAS is 18.09.6 but as I'm pretty new to Docker, I suspect I've just typed something wrong.
Anyone spot my error?

How to execute a script located in the runner from the ci-pipeline?

I have a gitlab-runner image as follows:
Dockerfile
FROM alpine:3.6
RUN apk add --no-cache curl bash
COPY trigger-jenkins /usr/local/bin/trigger-jenkins
ENTRYPOINT ["/bin/bash"]
Its purpose is to trigger a Jenkins job. Running this with:
docker run -ti jenkins-runner:latest trigger-jenkins job_name
works perfectly fine. But when I tried to do the same by:
.gitlab-ci.yml
Jenkins Trigger:
script:
- trigger-jenkins job_name
tags:
- Jenkins
The pipeline fails like this:
Running with gitlab-ci-multi-runner 9.3.0 (3df822b)
on Jenkins Trigger (12475d61)
Using Docker executor with image jenkins-runner:latest ...
Using docker image sha256:44dedf0b3485e0e57107e2745739e1a252fb64c4161465e1b5ccc1119a1183bf for predefined container...
Using docker image jenkins-runner:latest ID=sha256:4760a8ef9139ee9c9a56c686de780fc49e176fe4294e1f0db4f431e117b6811c for build container...
Running on runner-12475d61-project-6-concurrent-0 via cc960a3794a0...
Cloning repository...
Cloning into '/builds/dev/Project'...
Checking out 874b2eac as test/jenkins...
Skipping Git submodules setup
/bin/sh: /bin/sh: cannot execute binary file
/bin/sh: /bin/sh: cannot execute binary file
ERROR: Job failed: exit code 126
I searched for the error code, but was not able to find an explanation.
What am I missing?
The issue was not because of exec. The issue was probably this, your entrypoint was /bin/bash and Gitlab CI was trying to execute /bin/sh which is an executable. Leads to something like below
/bin/bash /bin/sh command args
Which is what the complaint we see as. Cannot execute binary file. What your entrypoint should have been is below
ENTRYPOINT ["/bin/bash", "-c"]
Which would have made sure a command gets execute by bash and whether it is another shell or bash it would have worked. No need to modify and created entrypoint.sh
I continued my research and found the repository of the official maven docker images.
They solved a similar problem by creating a mvn-entrypoint.sh. So I tried the same:
entrypoint.sh
#!/bin/sh
export PATH=$PATH:/usr/local/bin/
exec "$#"
This did the trick.

Resources