ENTRYPOINT just refuses to exec or even shell run - dockerfile

This is my 3rd day of tear-your-hair-out since the weekend and I just cannot get ENTRYPOINT to work via gitlab runner 13.3.1, this for something that previously worked with a simple ENTRYPOINT ["/bin/bash"] but that was using local docker desktop and using docker run followed by docker exec commands which worked like a synch. Essentially, at the end of it all I previously got a WAR file built.
Currently I build my container in gitlab runner 13.3.1 and push to s3 bucket and then use the IMAGE:localhost:500/my-recently-builtcontainer and then try and do whatever it is I want with the container but I cannot even get ENTRYPOINT to work, in it's exec form or in shell form - atleast in the shell form I get to see something. In the exec form it just gave "OCI runtime create failed" opaque errors so I shifted to the shell form just to see where I could get to.
I keep getting
sh: 1: sh: echo HOME=/home/nonroot-user params=#$ pwd=/ whoami=nonroot-user script=sh ENTRYPOINT reached which_sh=/bin/sh which_bash=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; ls -alrth /bin/bash; ls -alrth /bin/sh; /usr/local/bin/entrypoint.sh ;: not found
In my Dockerfile I distinctly have
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN bash -c "ls -larth /usr/local/bin/entrypoint.sh"
ENTRYPOINT "echo HOME=${HOME} params=#$ pwd=`pwd` whoami=`whoami` script=${0} ENTRYPOINT reached which_sh=`which sh` which_bash=`which bash` PATH=${PATH}; ls -alrth `which bash`; ls -alrth `which sh`; /usr/local/bin/lse-entrypoint.sh ;"
The output after I build the container in gitlab is - and I made sure anyone has rights to see this file and use it - just so that I can proceed with my work
-rwxrwxrwx 1 root root 512 Apr 11 17:40 /usr/local/bin/entrypoint.sh
So, I know it is there and all the chmod flags indicate anybody can look at it - so I am so perplexed why it is saying NOT FOUND
/usr/local/bin/entrypoint.sh ;: not found
entrypoint.sh is ...
#!/bin/sh
export PATH=$PATH:/usr/local/bin/
clear
echo Script is $0
echo numOfArgs is $#
echo paramtrsPassd is $#
echo whoami is `whoami`
bash --version
echo "About to exec ....."
exec "$#"
It does not even reach inside this entrypoint.sh file.

Related

Where do I put `.aws/credentials` for Docker awslogs log-driver (and avoid NoCredentialProviders)?

The Docker awslogs documentation states:
the default AWS shared credentials file (~/.aws/credentials of the root user)
Yet if I copy my AWS credentials file there:
sudo bash -c 'mkdir -p $HOME/.aws; cp .aws/credentials $HOME/.aws/credentials'
... and then try to use the driver:
docker run --log-driver=awslogs --log-opt awslogs-group=neiltest-deleteme --rm hello-world
The result is still the dreaded error:
docker: Error response from daemon: failed to initialize logging driver: failed to create Cloudwatch log stream: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors.
Where does this file really need to go? Is it because the Docker daemon isn't running as root but rather some other user and, if so, how do I determine that user?
NOTE: I can work around this on systems using systemd by setting environment variables. But this doesn't work on Google CloudShell where the Docker daemon has been started by some other method.
Ah ha! I figured it out and tested this on Debian Linux (on my Chromebook w/ Linux VM and Google CloudShell):
The .aws folder must be in the root folder of the root user not in the $HOME folder!
Based on that I was able to successfully run the following:
pushd $HOME; sudo bash -c 'mkdir -p /.aws; cp .aws/* /.aws/'; popd
docker run --log-driver=awslogs --log-opt awslogs-region=us-east-1 --log-opt awslogs-group=neiltest-deleteme --rm hello-world
I initially figured this all out by looking at the Docker daemon's process information:
DOCKERD_PID=$(ps -A | grep dockerd | grep -Eo '[0-9]+' | head -n 1)
sudo cat /proc/$DOCKERD_PID/environ
The confusing bit is that Docker's documentation here is wrong:
the default AWS shared credentials file (~/.aws/credentials of the root user)
The true location is /.aws/credentials. I believe this is because the daemon starts before $HOME is actually defined since it's not running as a user process. So starting a shell as root will tell you a different story for tilde or $HOME:
sudo sh -c 'cd ~/; echo $PWD'
That outputs /root but using /root/.aws/credentials does not work!

docker image runs ok locally but in ECS I get a message: executable file not found in $PATH

I've a weird error, I'm trying to run a python script in ECS, the dockerfile is pretty basic:
FROM python:3.8
COPY . /
RUN pip install -r requirements.txt
CMD ["python", "./get_historical_data.py"]
building this in my local machine works perfect,
docker run --network=host historical-price
I uploaded this image to ECR and run on ECS, a basic config, just set container name, pointing the Image to my ECR repo and set some environment variables...when I run this I get
Status reason CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknown
but (really weird) if I enter in the EC2 server and run the container manually
docker run -it -e TICKER='SOL/USDT' -e EXCHANGE='BINANCE' -e DB_HOST='xxx' -e DB_NAME='xxx' -e DB_PASSWORD='xxx' -e DB_PORT='xxx' -e DB_USER='xxx' xxx.dkr.ecr.ap-southeast-2.amazonaws.com/xxx:latest /bin/bash
I can see this running ok...
I've tried several dockerfiles, using
CMD python ./get_historical_data.py
or using python3 command instead of python
also I tried to skip the CMD command in the Dockerfile and add this in the ECS task definition
nothing work...
I really don't know what can be happen here because the last week I ran a similar task and this worked perfectly, hope you can help me
thank you, please let me know if you need more details

Dockerfile Entrypoint - still exiting with exec $#?

I'm working on a container to use megacmd (CLI syncing utility from Mega.nz, storage provider).
Relatively new to Dockerfiles, I've successfully made a dockerfile that will install MegaCMD, and login, but once it does that, it stops the container.
In my compose file I have set tty: true, thinking that would keep it alive, but it does not.
FROM ubuntu:groovy
ENV email=email#example.com
ENV password=notyourpassword
RUN apt-get update \
....more stuff here
COPY megalogin.sh /usr/bin/local/megalogin.sh
ENTRYPOINT ["sh", "/usr/bin/local/megalogin.sh"]
####Works up to here but the container still stops when finished the login script
megalogin.sh
#!/bin/sh
mega-login ${email} ${password}
mega-whoami
What do I need to do to make this thing to stay running?
I have tried the exec "$#" at the end of the script but that didnt make any difference.
When you run your container append the tail -f /dev/null to the docker run command e.g.
docker run -d [container-name] tail -f /dev/null
You should then be able to exec into the running container using docker exec [container-name] /bin/bash
So not the exact best solution, but in the compose file I put:
And it worked.
tty: true
stdin_open: true

Echo command in Dockerfile

echo "Hi There - Welcome to Docker POC">C:/Users/abc/xyz/POC/poc.html
The above echo command works from windows powershell but the same does not work when it is included in a Dockerfile as given below.
RUN echo "Hi There - Welcome to Docker POC">C:/Users/abc/xyz/POC/poc.html
The Error is : System cannot find the path specified.
Pls help.
This is because the path you give at the end of the RUN command in the Dockerfile is into the container.
You probably want to run the command into a docker container. If so, please run:
docker run --rm -v C:/Users/abc/xyz/POC/:/POC busybox sh -c 'echo "Hi There - Welcome to Docker POC" > /POC/poc.html'
And you will see 'poc.html' file in 'C:/Users/abc/xyz/POC/'.
Tell if I misunderstood your request.

Aborting AWS operations/ installing Anaconda with numbapro

Two part question, would really appreciate help on either part. I'm attempting to install Anaconda followed by numbapro on AWS EB. My options.config in .ebextensions looks like this:
commands:
00_download_conda:
command: 'wget http://repo.continuum.io/archive/Anaconda2-4.3.0-Linux-x86_64.sh'
test: test ! -d /anaconda
01_install_conda:
command: 'bash Anaconda2-4.3.0-Linux-x86_64.sh'
command: echo 'Finished installing Anaconda'
test: test ! -d /anaconda
02_install_cuda:
command: 'export PATH=$PATH:$HOME/anaconda2/bin'
command: echo 'About to install numbapro'
command: 'conda install -c anaconda numbapro'
Whenever I attempt to deploy this I run into a timeout and when I try and manually stop the current processes from the console I get an error saying that the environment is not in a state where I can abort the current operation or view any log files.
There are a couple of problems here.
First, you need to make sure that you're properly indenting your YAML file, as YAML is sensitive to whitespace. Your file should look like this:
commands:
00_download_conda:
command: 'wget http://repo.continuum.io/archive/Anaconda2-4.3.0-Linux-x86_64.sh'
test: test ! -d /anaconda
01_install_conda:
command: 'bash Anaconda2-4.3.0-Linux-x86_64.sh'
...
Next, you can only have one command: entry per command. The echo commands aren't particularly valuable, as you can see what commands are being executed by looking at /var/log/eb-activity.log. You can also combine the export PATH line with conda install something like this:
PATH=$PATH:$HOME/anaconda2/bin conda install -c anaconda numbapro
If you're still having trouble after you clear up those items, check (or post here) eb-activity.log to see what's going on.
Refer to the documentation for more details.