/usr/src/pipeline.sh: line 4: docker: not found - windows

Building a docker image using a file called pipeline.sh, however I am receiving an error message stating:
/usr/src/pipeline.sh: line 4: docker: not found
Pipeline.sh file
#! /bin/sh
#***Sample Script to build, test and push containerized Node.js applications ***
#build docker image
docker image build -t $HUB_USER/$REPOSITORY:$TAG .
#Run all unit tests
docker container run $HUB_USER/$REPOSITORY:$TAG npm test
#Login to docker Hub
docker Login -u $HUB_USER -p $HUB_PWD
#Push the image to Docker Hub
docker image push $HUB_USER/$REPOSITORY:$TAG
Docker Image File:
FROM alpine:latest
RUN apk update $$ apk add docker
WORKDIR /usr/src/app
COPY . /usr/src/
CMD /usr/src/pipeline.sh
Command:
PS C:\Users\tab45\fod\ch08\builder> docker container run --rm --name builder
-v /var/run/docker.sock:/var/run/docker.sock
-v /c/users/tab45/fod/ch08/sample-app:/usr/src/app
-e HUB_USER='username'
-e HUB_PWD='password'
-e repository='ch08-sample-app' builder:1.0
Output
/usr/src/pipeline.sh: line 4: docker: not found
/usr/src/pipeline.sh: line 6: docker: not found
/usr/src/pipeline.sh: line 8: docker: not found
/usr/src/pipeline.sh: line 10: docker: not found
codeoutput

Related

Why have I an error message "invalid reference format" when working with Docker?

I'm following the below tutorial and they use docker. I got an error When I tried to mount my local folder to the container.
https://www.youtube.com/watch?v=bhBSlnQcq2k
docker run --name some-nginx -v $(pwd):/usr/share/nginx/html:ro -d -p 8080:80 nginx
I got the following error:
docker: invalid reference format.
I am using Windows 10 PowerShell, Visual Studio Code, and Nginx image. Any ideas are highly appreciated.
with powershell you should use ${PWD} instead of $(pwd)
then you should do
docker run --name some-nginx -v ${PWD}:/usr/share/nginx/html:ro -d -p 8080:80 nginx
possible duplicate of : Mount current directory as a volume in Docker on Windows 10

Issue running project using docker

I am trying to install docker in my windows machine and run the project with given command.
docker run -it -p 8000:80 --rm -v "$PWD":/var/www/html registry.XXXXXX/docker-images/legacy-admin:master
I am running windows so instead of $PWD, I used D:/projects/
But I am getting the following error
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: invalid reference format.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'
docker run -it -d -p 8000:80 --rm -v "$PWD":/var/www/html registry.XXXXXX/docker-images/legacy-admin:maste
Try running above lines

Run docker with aliased port and access to bash

I'm trying to start a docker snapshot and connect to it via bash but also alias its port so I can access it from my local system at localhost:3333, this is what I have:
docker run -d -p 3333:3000 -t -i mysnapshot /bin/bash
However while it does start the container image it doesn't connect to it via bash
This is the output it generates:
3c86ca433d645c6c11315e89bbeaf89f072e2d1fa83213d4c4256c4a1af98322
and this is the dockerfile used to build the image:
FROM node:10
Setting working directory. All the path will be relative to WORKDIR WORKDIR /usr/src/app
Installing dependencies COPY package*.json ./ RUN npm install
Copying source files COPY . .
Building app
RUN npm run build
Running the app CMD [ "npm", "start" ]
You used -d option in docker run command, which will run the container in detached mode in the background.
Please check this out.
To get into the bash run
docker exec -it <conatiner-id> /bin/bash
where <container-id> can be retrieved from docker ps output.
Also as per your dockerfile you want npm start to be the first process in the container, so while running docker run command don't specify /bin/bash because it will override the CMD npm start mentioned in the dockerfile.
Hope this helps, let me know.
It seems you may need to overwrite your entrypoint because last line of your dockerfile mention your start command is npm start.
Also, -d detached mode is not needed.
Try this one:
docker run -it -p 3333:3000 --entrypoint=/bin/bash mysnapshot

how to mount windows directory to a windows container

I am trying to mount a windows directory inside a windows docker container that runs with image microsoft/aspnetcore-build:2.0
I tried below commands
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\dotnet
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\\
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore
docker run -d microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\\dotnet
All the above commands threw the error
docker: Error response from daemon: container 66e8c16cdf607c9e7ecb049963c602d22c9850f331e3d08c3acc557db4d40814 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"-v dotnetcore:c:\\dotnet","WorkingDirectory":"C:\\","Environment":{"ASPNETCORE_PKG_VERSION":"2.0.8","ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_SDK_DOWNLOAD_SHA":"5cae6f4c577182e7d84d991b9d20162c1a76ce17f65b7b52a7e6df8d98ec389e03626f61969eaed4f23a5f6c96a3ab188e71a0b94cc58f86e485ac9296c4af64","DOTNET_SDK_DOWNLOAD_URL":"https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.200/dotnet-sdk-2.1.200-win-x64.zip","DOTNET_SDK_VERSION":"2.1.200","DOTNET_USE_POLLING_FILE_WATCHER":"true","NODE_DOWNLOAD_SHA":"3d3d72c5c93a50d5a19f65f0de196b5237792a99b89fac2b61e62da4f566c842","NODE_VERSION":"6.13.0","NUGET_XMLDOC_MODE":"skip","RestoreUseSkipNonexistentTargets":"false"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[30,131]}.
Any help to resolve this will be highly appreciated
You need to put -v parameter before image name

docker sharing host directory

I used to share my host diretory with a docker container with the command (osx):
docker run --name tensorflower -it -p 8888:8888 -v /c/foo/labs:/home tensorflow/tensorflow
on windows it used to work with:
docker run --name tensorflower -it -p 8888:8888 -v //c/foo/labs:/home tensorflow/tensorflow
But now it does not work on windows. I tried both -v variants. As I do not get any error messages, I have no glue where to dig in to solve the problem.
How can I share the host directory c:\foo\labs with my docker container?
Or at least get some more informaton regarding the error?
Docker version 17.09.1-ce, build 19e2cf6 on windows 10

Resources