File not being bind mounted to docker-compose - docker

I am running a docker-compose test; part of my stack that will perform the actual tests is the following service
tester:
image: tutum/curl:latest
volumes:
- ./ci/wait-for-it.sh:/usr/local/bin/wait-for-it.sh
- ./webhooks:/app/webhooks
depends_on:
- sut
command: ["wait-for-it.sh", "sut:8080", "-t", "240", "--", "sh", "pytest /app/webhooks"]
The command fails as follows:
ERROR: for 0114c9206690_alerta-_tester_1 Cannot start service tester: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"wait-for-it.sh\": executable file not found in $PATH": unknown
ERROR: for tester Cannot start service tester: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"wait-for-it.sh\": executable file not found in $PATH": unknown
The file being mounted does exist:
▶ ls docker-compose.test.yaml
docker-compose.test.yaml
Workspace/systems-utils/ alerta_dev_infra ✗ 1d ⚑ ◒
▶ ls ./ci/wait-for-it.sh
./ci/wait-for-it.sh
What is more, when trying to bind mount a non-existent file, instead of getting a mount-related error, i get the same error as above
tester:
image: tutum/curl:latest
volumes:
- ./ci/foofile.sh:/usr/local/bin/wait-for-it.sh
- ./webhooks:/app/webhooks
depends_on:
- sut
command: ["wait-for-it.sh", "sut:8080", "-t", "240", "--", "sh", "pytest /app/webhooks"]
$ docker-compose -f docker-compose.test.yaml up -d
ERROR: for tester Cannot start service tester: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"wait-for-it.sh\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.
What am I missing?
edit: Regarding the PATH issue mentioned, here it is:
▶ docker run -it tutum/curl:latest printenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=1f3090676fa0
TERM=xterm
HOME=/
What is more, the tester service configuration is the exact same as in this project which runs perfectly.
As for the permissions issue:
Workspace/systems-utils/alerta-workable alerta_dev_infra ✗ 1d ⚑ ◒ ⍉
▶ ls -al ./ci/wait-for-it.sh
-rwxr-xr-x 1 pkaramol staff 5.1K Sep 6 22:02 ./ci/wait-for-it.sh

The error message is pretty self-explanatory - wait-for-it.sh is not on $PATH.
You need either add /usr/local/bin to $PATH or change command to
command: ["/usr/local/bin/wait-for-it.sh", "sut:8080", "-t", "240", "--", "sh", "pytest /app/webhooks"]
See also accepted answer to this question for why /usr/local/bin might not be in path.

Looks like it could not find "executable file in $PATH"
So let's try to set executable permissions on ./ci/wait-for-it.sh file:
$ chmod +x ./ci/wait-for-it.sh

Related

"/bin/sh: [/bin/sh,: not found" response when spining up kilna/liquibase-postgres

when spinning up docker image [kilna/liquibase-postgres], we are getting:
"/bin/sh: [/bin/sh,: not found"
As a response in the container log and the container is exiting abruptly.
Additional Note: We are using macOS Catalina and default bash is zsh.
Any pointers appreciated. Thank you
The command given in the Dockerfile is incorrect.
"Cmd": [
"/bin/sh",
"-c",
"['/bin/sh', '-i']"
],
It has nested /bin/sh. Argument for the flag -c should be a single string. It can not be an array.
So, it gives docker run kilna /bin/sh: [/bin/sh,: not found error.
Change the CMD as CMD ["/bin/sh", "-c", "/bin/sh -i"], build and run.
$ docker run -it kilna
/ #

How to pass argument for a configuration file in JuPyterhub's deployment?

I want to install envkey in my docker image which requires a key-value pair. I have the key-value pair with me but I am unable to figure out as to how do I install it in my docker image using those arguments and then deploy the same on jupyterhub.
I tried reading other deployments of mine which use envkey. Here is how it goes:
1. I have a Makefile and I run the command sudo make dev config=aviral.cfg
2. The dev command in the Makefile is as follows:
dev:
docker build -t $(IMAGE) -f Dockerfile.dev . && docker tag $(IMAGE) $(ALIAS)
#echo "\nCreate docker container.."
CONFIG=$(config) IMAGE=$(IMAGE) docker-compose -f docker-compose.yml up -d --scale test=0 --scale airflow_worker=0
#echo "\n$(GREEN)Done.$(NO_COLOR)\n"
#echo "Try airflow at http://localhost:8080."
#echo "and flower at http://localhost:5555."
The docker-compose file is:
airflow_worker:
image: ${IMAGE}:latest
restart: always
depends_on:
- airflow_scheduler
# ports:
# - 8793:8793
# environment:
# - GOOGLE_APPLICATION_CREDENTIALS=/gcloud/cloud.json
env_file:
- ${CONFIG}
command: worker
As you can see, the env_file is passed on.
I am unable to deduce how to do this same in the JuPyterHub.
The helm chart is here(https://jupyterhub.github.io/helm-chart/jupyterhub-0.8.2.tgz). And my config is:
proxy:
secretToken: "yada_yada"
singleuser:
image:
name: yada_yada.dkr.ecr.ap-south-1.amazonaws.com/demo
tag: 12h
lifecycleHooks:
postStart:
exec:
command: ["/bin/sh", "-c", 'ipython profile create; cd ~/.ipython/profile_default/startup; echo ''run_id = "sample" ''> aviral.py']
imagePullSecret:
enabled: true
registry: yada_yada.dkr.ecr.ap-south-1.amazonaws.com
username: aws
email: aviral#yada_yada.com
password: yada_yada
In my config file, I pass variables as:
ENVKEY=my_personal_envkey
I expect to have my configs passed in the docker, or perhaps I write a proper Makefile for this stuff, as of now, I am facing this error:
Step 19/32 : RUN curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh | bash
---> Running in 35bc1cf0e1c8
envkey-source 1.2.9 Quick Install
Copyright (c) 2019 Envkey Inc. - MIT License
https://github.com/envkey/envkey-source
Downloading envkey-source binary for linux-amd64
Downloading tarball from https://github.com/envkey/envkey-source/releases/download/v1.2.9/envkey-source_1.2.9_linux_amd64.tar.gz
envkey-source is installed in /usr/local/bin
Installation complete. Info:
bash: line 97: 29 Segmentation fault envkey-source -h
The command '/bin/sh -c curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh | bash' returned a non-zero code: 139
Although this question alone should be good enough to give you the picture but for the sake of context(if), here are some of the questions:
1. How do I make jupyter-hub access my private docker image repository?
2. Unable to run a lifecycle command from config.yaml while deploying jupyterhub
3. How to have file written automatically in the startup folder when a new user signs up/in on JuPyter hub?
Probably you get this error because install.sh script tries to add envkey-source binary under /usr/local/bin directory and then tries to run envkey-source -h and fails. Check if user(if non-root) have permission to do that or if /usr/local/bin directory exists in container image.
Hope it helps!

Docker entrypoint can't find file

I have a very simple docker build file:
FROM openjdk:10
ENV JENAVERSION=3.7.0
RUN mkdir /fuseki
RUN wget http://apache.claz.org/jena/binaries/apache-jena-fuseki-$JENAVERSION.tar.gz -P /tmp \
&& tar -zxvf /tmp/apache-jena-fuseki-$JENAVERSION.tar.gz -C /tmp \
&& mv -v /tmp/apache-jena-fuseki-$JENAVERSION/* /fuseki
EXPOSE 3030
ENTRYPOINT ["/bin/bash", "/fuseki/fuseki-server"]
I've tried different variations on CMD and ENTRYPOINT, but nothing allows "fuseki-server" to execute. Always a "No such file or directory" error. If I manually create an empty container from openjdk:10, and execute each command manually, it works fine. What's going on?
I think the issue is the line ending - the entrypoint needs to have LF line ending.
I get the same error when my entrypoint has CLRF line ending.
If I build and run your Dockerfile, I get a different error from what you've described. I see:
Can't find jarfile to run
If you look at the fuseki-server shell script, it's trying to find the jar file relative either to your current directory or to the $FUSEKI_HOME environment variable:
export FUSEKI_HOME="${FUSEKI_HOME:-$PWD}"
if [ ! -e "$FUSEKI_HOME" ]
then
echo "$FUSEKI_HOME does not exist" 1>&2
exit 1
fi
JAR1="$FUSEKI_HOME/fuseki-server.jar"
JAR2="$FUSEKI_HOME/jena-fuseki-server-*.jar"
JAR=""
So if you set the FUSEKI_HOME environment variable in your
Dockerfile:
ENV FUSEKI_HOME=/fuseki
Then the container starts up without errors:
[2018-06-04 14:02:17] Server INFO Apache Jena Fuseki 3.7.0
[2018-06-04 14:02:17] Config INFO FUSEKI_HOME=/fuseki
[2018-06-04 14:02:17] Config INFO FUSEKI_BASE=/run
[2018-06-04 14:02:17] Config INFO Shiro file: file:///run/shiro.ini
[2018-06-04 14:02:18] Server INFO Started 2018/06/04 14:02:18 UTC on port 3030
Wow... After going through #larsk's suggestion it occurred to me to change the entrypoint to
ENTRYPOINT ["tail", "-f", "/dev/null"]
and go into the container to see what was actually there. It turns out that I was accidently overwriting the /fuseki folder with a volume declaration in the compose file I was using. (facepalm...)

Bringing up the hyperledger network?

$ ./byfn.sh -m up
.
Starting with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
Starting peer1.org2.example.com ...
Starting peer1.org1.example.com ...
Starting peer0.org1.example.com ...
Starting peer0.org2.example.com ...
Starting peer0.org1.example.com ... done
Starting cli ... done
/bin/bash: ./scripts/script.sh: No such file or directory
/bin/bash: ./scripts/script.sh: No such file or directory
/bin/bash: ./scripts/script.sh: No such file or directory
/bin/bash: ./scripts/script.sh: No such file or directory
/bin/bash: ./scripts/script.sh: No such file or directory
I get the above error on building up my first network ?
Kindly help.
(assuming fabric-samples folder is downloaded and the latest version 0.1.1 is installed, and no changes are made to any file)

Dockerfile throwing an error "no such file or directory"

My docker file looks like
FROM grpc/python
CMD ["/bin/ls /"]
It is throwing an error:
container_linux.go:265: starting container process caused "exec: \"/bin/ls /\": stat /bin/ls /: no such file or directory"
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"/bin/ls /\": stat /bin/ls /: no such file or directory".
You need to separate the command from the arguments:
CMD ["/bin/ls", "/"]
CMD accepts the following formats:
CMD ["executable","param1","param2"] (exec form, this is the preferred form)
CMD ["param1","param2"] (as default parameters to ENTRYPOINT)
CMD command param1 param2 (shell form)
You have extra space after ls in CMD command on second row

Resources