runing docker container can't find copied script in dockerimage - dockerfile

My docker file looks like this:
WORKDIR $BUILD_OUTPUT_DIR
ENV TEMPLATECONF=$BUILD_INPUT_DIR/$PROJECT/sources/meta-$PROJECT/custom
COPY prep.sh /home/$USER_NAME/yocto/input/
COPY fetch-repos.sh /home/$USER_NAME/yocto/input/
USER root
RUN chmod +x /home/$USER_NAME/yocto/input/prep.sh
RUN chmod +x /home/$USER_NAME/yocto/input/fetch-repos.sh
RUN ls -l /home/$USER_NAME/yocto/input/*.sh
CMD ["sh","-c", "./home/$USER_NAME/yocto/input/prep.sh && bitbake $PROJECT"]
I run the container like this in azure ACR:
- task: Docker#2
inputs:
containerRegistry: '2460-ACR-connection-TMM'
command: 'login'
- script: |
docker run 2460testacr.azurecr.io/2460testacr.2460testacr.azurecr.io:$(tag)
But I have got this error, would you help?
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/cce02da3-0534-40a8-81c5-52ed45134050.sh
sh: ./home/rtr2460/yocto/input/prep.sh: No such file or directory

./root/prep.sh: No such file or directory
Tells you that the file at that location does not exist or the user has no access rights to that location. You will need to find the exact location where this path is being assumed in your configuration tries to use this path. It is either legitimate or not.
If it is legitimate, then there are two possibilities: it is either missing or your user does not have the necessary privileges.
If it is a privilege problem, then you can add a line that adds the necessary privileges. Otherwise, if it is missing, then you will need to find out why it is missing. Chances are that your
COPY prep.sh /home/$USER_NAME/yocto/input/
line is copying the file to the wrong location.
Otherwise, if it is illegitimate, then there is a bug in your configuration (that you can find by searching for anything related to this filename) and fix it.

Related

QuestDB could not open file [errno=2, path=] although file exists

I have launched QuestDB through this way:
docker run -p 9000:9000 --memory="100g" --name docker_questdb -v questdb/questdb
After uncommenting the following line in the server.conf:
cairo.sql.copy.root=
Then running the import command:
COPY d1temp FROM '/home/user/d1_data/d1.csv'
would generate the following error:
QuestDB could not open file [errno=2, path=/home/user/d1_data/d1.csv]
However, the file actually exists:
less /home/user/d1_data/d1.csv
s0,s1,s2
0.093684,0.601416,0.020954
0.181069,0.323754,0.624349
0.665080,0.735986,0.346020
0.317661,0.295168,0.540372
0.702641,0.381416,0.251456
0.056244,0.428558,0.985173
0.893521,0.018625,0.100640
Could this solved please? In the meantime, how could this be fixed?
Os errno=2 is 'No such file or directory'.
If path you specified is outside the container then you need to make sure it's shared via -v. It's best to enter the container and check that file exists inside (e.g. with docker exec) .
Lastly - the path used in copy command is not absolute but relative to cairo.sql.copy.root so if cairo.sql.copy.root is set to '/home/user/d1_data/' then command should look like :
COPY d1temp FROM 'd1.csv'

Passing CMD line arguments to docker entry point in Python

So I've got a docker file like so:
FROM frolvlad/alpine-python2
MAINTAINER *REDACTED*
COPY . .
RUN pip install -r requirements.txt
RUN python misc_scripts/gen_hosts.py
RUN python misc_scripts/strip_delims.py
RUN python runparse.py -spc -spi
ENTRYPOINT ["python", "rebuild.py"]
And using the Docker API in python I'm trying to run the container like so
logs = client.containers.run(image_id, name=str(_uuid), entrypoint=['-m ME3400', '-mi NONE'])
However I get the following error
500 Server Error: Internal Server Error ("OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-m ME3400\": executable file not found in $PATH": unknown")
I assume I'm doing it wrong, anyone know how/why this isn't working?
As you said in the title of your question, it should be the command argument you expect. Follow the source code on github(starting line 484), it should be more specific.
Change your code as below:
logs = client.containers.run(image_id, name=str(_uuid), command=['-m ME3400', '-mi NONE'])
Always note that CMD will treat as ENTRYPOINT's args when it exists. But if you specify another ENTRYPOINT(in your case: ['-m ME3400', '-mi NONE']), the original one(["python", "rebuild.py"]) will be overwritten.

Nix Gradle dist - Failed to load native library 'libnative-platform.so' for Linux amd64

I am trying to build a Freeplane derivation based on Freemind, see: https://github.com/razvan-panda/nixpkgs/blob/freeplane/pkgs/applications/misc/freeplane/default.nix
{ stdenv, fetchurl, jdk, jre, gradle }:
stdenv.mkDerivation rec {
name = "freeplane-${version}";
version = "1.6.13";
src = fetchurl {
url = "mirror://sourceforge/project/freeplane/freeplane%20stable/freeplane_src-${version}.tar.gz";
sha256 = "0aabn6lqh2fdgdnfjg3j1rjq0bn4d1947l6ar2fycpj3jy9g3ccp";
};
buildInputs = [ jdk gradle ];
buildPhase = "gradle dist";
installPhase = ''
mkdir -p $out/{bin,nix-support}
cp -r ../bin/dist $out/nix-support
sed -i 's/which/type -p/' $out/nix-support/dist/freeplane.sh
cat >$out/bin/freeplane <<EOF
#! /bin/sh
JAVA_HOME=${jre} $out/nix-support/dist/freeplane.sh
EOF
chmod +x $out/{bin/freeplane,nix-support/dist/freeplane.sh}
'';
meta = with stdenv.lib; {
description = "Mind-mapping software";
homepage = https://www.freeplane.org/wiki/index.php/Home;
license = licenses.gpl2Plus;
platforms = platforms.linux;
};
}
During the gradle build step it is throwing the following error:
building path(s)
‘/nix/store/9dc1x2aya5p8xj4lq9jl0xjnf08n7g6l-freeplane-1.6.13’
unpacking sources unpacking source archive
/nix/store/c0j5hgpfs0agh3xdnpx4qjy82aqkiidv-freeplane_src-1.6.13.tar.gz
source root is freeplane-1.6.13 setting SOURCE_DATE_EPOCH to timestamp
1517769626 of file freeplane-1.6.13/gitinfo.txt patching sources
configuring no configure script, doing nothing building
FAILURE: Build failed with an exception.
What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. builder for ‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed with exit code 1 error: build of
‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed
Running gradle dist from terminal works fine. I'm guessing that maybe one of the globally installed Nix packages provides a fix to the issue and they are not visible during the build.
I searched a lot but couldn't find any working solution. For example, removing the ~/.gradle folders didn't help.
Update
To reproduce the issue just git clone https://github.com/razvan-panda/nixpkgs, checkout the freeplane branch and run nix-build -A freeplane in the root of the repository.
Link to GitHub issue
Maybe you just don't have permission for the folder/file
sudo chmod 777 yourFolderPath
you can also : sudo chmod 777 yourFolderPath/* (All folder)
Folder will not be locked,then You can use it normally
[At least I succeeded。。。]
EX:
sudo chmod 777 Ruby/
now ,that's ok
To fix this error: What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64. do the following:
Check if your Gradle cache (**~user/.gradle/**native folder exist at all or not).
Check if your Gradle cache (~user/.gradle/native folder exist and the file in question i.e. libnative-platform.so exists in that directory or not).
Check if the above folder ~user/.gradle or ~/.gradle/native or file: ~/.gradle/native/libnative-platform.so has valid permissions (should not be read-only. Running chmod -R 755 ~/.gradle is enough).
IF you don't see native folder at all or if your native folder seems corrupted, run your Gradle task ex: gradle clean build using -g or --gradle-user-home option and pass it's value.
Ex: If I ran mkdir /tmp/newG_H_Folder; gradle clean build -g /tmp/newG_H_Folder, you'll see Gradle will populate all the required folder/files (that it needs to run even before running any task or any option) are now in this new Gradle Home folder (i.e. /tmp/newG_H_Folder/.gradle directory).
From this folder, you can copy - just the native folder to your user's ~/.gradle folder (take backup of existing native folder in ~/.gradle first if you want to) if it already exists -or copy the whole .gradle folder to your ~ (home directory).
Then rerun your Gradle task and it won't error out anymore.
Gradle docs says:
https://docs.gradle.org/current/userguide/command_line_interface.html
-g, --gradle-user-home
Specifies the Gradle user home directory. The default is the .gradle directory in the user’s home directory.

Docker cookbook not finding Docker file

I've got a Dockerfile I'm trying to build using the following code:
docker_image 'wafflehouse' do
source '/root/dockerimages/CentOS'
action :build_if_missing
read_timeout 6000
write_timeout 6000
end
Using test kitchen the builds fail:
Error executing action `build_if_missing` on resource 'docker_image[wafflehouse]'
No such image: sha256:4eda692c08e0a065cg91d74e82ffxxxxxxxx07b4341ad61fa61771cc4659af60
Docker::Error::NotFoundError
If I reference the Dockerfile directly in the code:
docker_image 'wafflehouse' do
source '/root/dockerimages/CentOS/Dockerfile'
action :build_if_missing
read_timeout 6000
write_timeout 6000
end
The build fails to find the files that are referenced in the Dockerfile to copy:
FROM centos
COPY wafflehouse.repo /etc/yum.repos.d
COPY wafflehouse-artifacts.repo /etc/yum.repos.d
COPY wafflehouse-snapshot-artifacts.repo /etc/yum.repos.d
RUN yum install -y net-tools
CMD ["bash"]
The files are in the same directory as the Dockerfile. Any ideas on either of these?
I believe you have a problem with the dockerfile instead of Chef.
You should keep in mind that you are providing a relative path to the source of the files you want to copy.
In order to fix this, try using absolute paths for source and target paths, something like:
FROM centos
COPY /root/dockerimages/CentOS/wafflehouse.repo /etc/yum.repos.d/wafflehouse.repo
COPY /root/dockerimages/CentOS/wafflehouse-artifacts.repo /etc/yum.repos.d/wafflehouse-artifacts.repo
COPY /root/dockerimages/CentOS/wafflehouse-snapshot-artifacts.repo /etc/yum.repos.d/wafflehouse-snapshot-artifacts.repo
RUN yum install -y net-tools
CMD ["bash"]

Creating executable from python source file

I am following this guide for python 2.7 :
http://docs.python.org/tutorial/interpreter.html
I do all it says: I have a python file:
#! /usr/bin/env python
print "hello world !\n"
And from terminal, in the directory where is the file I type:
chmod +x hello_world.py
The file is name hello_world.py; But nothing happens, it doesn't print "hello world\n".
sorry if this is insultingly obvious, but
> chmod +x hello_world.py
only changes the file so that you can run it. next you need to actually run the file by typing:
> ./hello_world.py
hello world !
To give a bit more description: the chmod command changes the permissions of a file on a Unix-style system. The +x in the command:
chmod +x hello_world.py
Sets the "Executable" bit for the hello_world.py file, thereby making it a script which can be executed. Thus to run the script:
./hello_world.py
The ./ in front indicates that the file is in the current directory. Alternatively, you can always run a script by invoking the python interpreter directly (regardless of permissions) like so:
python hello_world.py