I am trying to build a docker image from a docker client (Windows) running this command:
docker --host a.b.c.d build --no-cache=true --build-arg CONFIGURATION=live -t imagename .
The docker host is also a Windows Docker but I get this error:
SECURITY WARNING: You are building a Docker image from Windows against
a non-Windows Docker host. All files and directories added to build
context will have '-rwxr-xr-x' permissions. It is recommended to
double check and reset permissions for sensitive files and
directories.
And then this one after the first attempt:
invalid character '<' looking for beginning of value
Anyone know why this happen? I had no error before, the only differences are in the code source. For information I am using Jenkins to build the project? Thanks.
UPDATE 1 - Dockerfile
FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ARG CONFIGURATION
EXPOSE 80
ADD src/MyFolder/bin/$CONFIGURATION/ /ContainerFolder
CMD /ContainerFolder/MyApp.exe
From thaJeztah on GitHub:
That warning was added, because the Windows filesystem does not have an option to mark a file as 'executable'. Building a linux image from a Windows machine would therefore break the image if a file has to be marked executable.
For that reason, files are marked executable by default when building from a windows client; the warning is there so that you are notified of that, and (if needed), modify the Dockerfile to change/remove the executable bit afterwards.
This is fixed now. The problem was in the Gateway Firewall, it was detecting a file sent in the build context as a Trojan. Probably Docker build context zip file or use different extensions.
Related
I cannot mount a local folder to a docker volume on docker-compose
so it is not accessible on docker-compose run cmd.
Here is a repo from the github https://github.com/up1/demo-k6-docker
When I follow readme on docker-compose run k6 run scripts/sample.js it gives me the following error all the time:
WARN[0000] The moduleSpecifier "scripts/sample.js" has no scheme but we will try to resolve it as remote module. This will be deprecated in the future and all remote modules will need to explicitly use "https" as scheme. ERRO[0000] The moduleSpecifier "scripts/sample.js" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker. Additionally it was tried to be loaded as remote module by prepending "https://" to it, which also didn't work. Remote resolution error: "Get "https://scripts/sample.js": dial tcp: lookup scripts on 127.0.0.11:53: no such host"
Tried:
specifically sharing folder in docker app settings window,
different github repos,
different mac laptops,
different setups Dockerfile copy and -v option on docker run
looking for similar questions
and docs
https://k6.io/docs/using-k6/modules#using-local-modules-with-docker
I would really appreciate some help, banging my head against the wall for a couple of days with this
Try this.
docker-compose run k6 run //scripts//sample.js
I'm running on docker desktop version 3.1.0 Windows 10 pro.
Solution
I have tried this example out on a windows 10 box which has WSL2 installed and integrated with the latest Docker version. After following the steps in the example and downloading the code in the linux subsystem, I am able to build the image and run the container. The website is also available on the browser when I browse to it on a browser running on Windows 10. However, when I create a file or folder in the container the same doesn't reflect in the host filesystem which in this case is the linux subsystem. Similarly, a file created in the host linux subsystem is not seen in the container's cli when I use the ls command.
I ran this commands to confirm that the folder has been mounted where 44711fc95366 is my container id
docker inspect -f "{{ .Mounts }}" 44711fc95366
This gives an output like so:
[{bind /home/userlab1/my-proj/getting-started/app /usr/src/app true
rprivate}]
If the mount point expressed above is correct, I should be able to create a file or folder in host subsystem on the path /home/userlab1/my-proj/getting-started/app and be able to see it at the /usr/src/app path in the container, correct?
The docker image has been created and run from the linux subsystem command line like so:
docker run -it -v ~/my-proj/getting-started/app:/usr/src/app -p 3001:3000 --name cntr-linux-todo
img-todo:in-linux
While the application runs, the files updated in the container don't reflect on the website that is running from the container, nor does a new file/folder created in the container be seen in the host subsystem and vice versa. What am I missing?
As you are using Windows's version of docker, it cannot see files/folders from WSL.
You can move ~/my-proj into C:\Users\user20358, and mount from there :
-v 'C:\Users\user20358\my-proj\getting-started\app:/usr/src/app'
Docker is a full development platform for creating containerized apps, and Docker for Windows is the best way to get started with Docker on Windows systems.
Start your favorite shell (cmd.exe, PowerShell, or other) to check your versions of docker and docker-compose, and verify the installation.
PS C:\Users\Docker> docker --version
Docker version 17.03.0-ce, build 60ccb22
PS C:\Users\Docker> docker-compose --version
docker-compose version 1.11.2, build dfed245
Your questions is not very specific but it appears that you are trying to containerize an asp.net web app, Here is a basic clue to what you want to accomplish by using docker.
Docker is a linux containers system means it's based on linux kernel and by installing docker in windows you are installing a linux guest machine to built your containers in and you will customize your containers to forward ports that will serve your app development from inside the container to your host machine, So basically How this is going to happen? after installing docker first docker needs a base image(linux image) to run your containers from, so a great place to find docker images is docker hub, so also for a basic scenario you need:
1) Pull an image.
2) Run a container based on this image.
To accomplish number 1: we will use microsoft dotnet official docker hub as an example.
docker pull microsoft/aspnetcore
docker pull: will pull the dotnet:latest image from docker hub, :latest is a tag specify the latest stable release of dotnet means if you want another runtime version you will use docker pull dotnet:runtime from the above dotnet official docker hub link you will find tags under Supported tags
To accomplish number 2: we need to run a container by using this image.
docker run -d -p 8000:80 --name firstwebapptest microsoft/aspnetcore
docker run: will create a container name firstwebapptest based on microsoft/aspnetcore forwarding the container port 80to the host port 8000 and all of that will run as a detached mode -d
And now check your browser localhost:8000
This is a very basic scenario using the docker command line tools.
So another way to accomplish this scenario is by using a dockerfile you will find How to use this image in microsoft dotnet official docker hub link, It assumes that you already in your app directory that contain your compiled myapp.dll. What will you do is create a file called dockerfile in this directory and write this inside:
FROM microsoft/aspnetcore
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "myapp.dll"]
FROM: base image that we already pulled
WORKDIR: that will be the directory inside the linux container
COPY: . . the first . is copying your host directory content inside the container the second . is your guest directory in that case will be /app
ENTREYPOINT: is the linux command that will run once this container is up and running in that case dotnet myapp.dll means you are running the command dotnet from the linux container inside the WORKDIR /app with all your host directory app structure that contains your compiled myapp.dll. that we already copied it COPY . .
so now we have the dockerfile all what we need is to build and run it.
docker build -t secondwebapptest .
docker run -d -p 8001:80 secondwebapptest
docker build: will build a container named -t secondwebapptest from . the dot refer to the dockerfile that you just built and that you are already in the working directory otherwise you have to specify a path to the docker file by using -f but that is not our case.
docker run: will run the container that already been created that named secondwebapptest based on forwarding the container port 80to the host port 8001 and all of that will run as a detached mode -d.
And now check your browser localhost:8001
How does this warning need to be addressed for a dart runtime docker image to be secure? The docker image will ultimately be hosted in the google cloud.
You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories."
The issue 20397 explains (credit: Sebastiaan van Stijn - thaJeztah)
That warning was added, because the Windows filesystem does not have an option to mark a file as 'executable'.
Building a linux image from a Windows machine would therefore break the image if a file has to be marked executable.
For that reason, files are marked executable by default when building from a windows client; the warning is there so that you are notified of that, and (if needed), modify the Dockerfile to change/remove the executable bit afterwards.
I like to add in the Dockerfile, after a COPY, a RUN CHMOD +x aFile_I_Just_Copied
I have created the following Dockerfile to create a Jenkins container.
It successfully works on OSX but when I try it on Windows 7, I get the following error when building the container.
Sending build context to Docker daemon 32.26 kB
Step 1 : FROM jenkins:latest
---> 997d1b2b89a5
Step 2 : COPY plugins.txt /var/jenkins_home/plugins.txt
---> Using cache
---> 632e6f94438c
Step 3 : RUN /usr/local/bin/plugins.sh /var/jenkins_home/plugins.txt
---> Running in a56c01d8afe0
Downloading credentials:1.24
curl: (3) Illegal characters found in URL
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
The command '/bin/sh -c /usr/local/bin/plugins.sh /var/jenkins_home/plugins.txt' returned a non-zero code: 3
This is my Dockerfile
FROM jenkins:latest
COPY plugins.txt /var/jenkins_home/plugins.txt
RUN /usr/local/bin/plugins.sh /var/jenkins_home/plugins.txt
# Adding default Jenkins Jobs
COPY jobs/unit-test-adapter.xml /usr/share/jenkins/ref/jobs/unit-test- adapter/config.xml
############################################
# Configure Jenkins
############################################
# Jenkins settings
COPY config/config.xml /usr/share/jenkins/ref/config.xml
# Jenkins Settings, i.e. Maven, Groovy, ...
COPY config/hudson.tasks.Maven.xml /usr/share/jenkins/ref/hudson.tasks.Maven.xml
COPY config/maven-global-settings-files.xml /usr/share/jenkins/ref/maven- global-settings-files.xml
# SSH Keys & Credentials
COPY config/credentials.xml /usr/share/jenkins/ref/credentials.xml
COPY config/ssh-keys/id_rsa /usr/share/jenkins/ref/.ssh/id_rsa
COPY config/ssh-keys/id_rsa.pub /usr/share/jenkins/ref/.ssh/id_rsa.pub
Does anyone know what the issue maybe? I'm confused as the plugins.shscript should be running inside of a build container rather than on Windows.
You should check the line breaks in your plugins.txt file. As described in this answer the issue may be caused by different line endings between Windows and Mac OS.