I have docker that runs the following file:
CMD /usr/local/bin/deploy.sh
First command in the deploy.sh file is
cd /home/app
It works in Docker on Linux, however in Docker on Windows I have following error:
/usr/local/bin/deploy.sh: 1: cd: can't cd to /home/app
What is the reason?
Here is my dockerfile:
FROM node:8
RUN apt-get update
RUN npm install pm2 -g
WORKDIR /home/app
ADD ./deploy.sh /usr/local/bin/deploy.sh
RUN chmod g+x /usr/local/bin/deploy.sh
RUN chmod u+x /usr/local/bin/deploy.sh
RUN mkdir /root/.ssh/
RUN touch /root/.ssh/known_hosts
RUN chmod +x /usr/local/bin/deploy.sh
RUN chmod 777 /usr/local/bin/deploy.sh
CMD /usr/local/bin/deploy.sh
It looks like you have CRLF (Windows) line ending and don't LF (linux) that is required for running .sh or working in linux in general (docker -> linux).
Open the deploy.sh file in notepad++ or IntelIJ IDE (I'm primary always working in InteljIJ with docker on Windows) and check line-ending.
I'm always using LF ending globaly for evry project with IntelIJ on Windows.
Related
I'm trying to run on my Ubuntu 20.04 machine a cluster of docker containers present in this repository :
https://github.com/Capgemini-AIE/ethereum-docker
My dockerfile:
FROM ethereum/client-go
RUN apk update && apk add bash
RUN apk add --update git bash nodejs npm perl
RUN cd /root &&\
git clone https://github.com/cubedro/eth-net-intelligence-api &&\
cd eth-net-intelligence-api &&\
npm install &&\
npm install -g pm2
ADD start.sh /root/start.sh
ADD app.json /root/eth-net-intelligence-api/app.json
RUN chmod +x /root/start.sh
ENTRYPOINT /root/start.sh
The commands:
sudo docker-compose build
sudo docker-compose up -d
are done correctly, but when execute:
docker exec -it ethereum-docker-master_eth_1 geth attach ipc://root/.ethereum/devchain/geth.ipc
i have this error:
ERROR: Container 517e11aef83f0da580fdb91b6efd19adc8b1f489d6a917b43cc2d22881b865c6 is restarting, wait until the container is running
The reason is, executing:
docker logs ethereum-docker-master_eth_1
result:\
/root/start.sh: line 5: /usr/bin/pm2: No such file or directory\
/root/start.sh: line 5: /usr/bin/pm2: No such file or directory\
/root/start.sh: line 5: /usr/bin/pm2: No such file or directory
Why do I have this problem? In the Docker file I have the command:
RUN npm install -g pm2
How can I solve the problem?
When I build an image with this dockerfile and then check the files in it I find that pm2 is installed at /usr/local/bin/pm2:
So you need to change the call in your script to
/usr/local/bin/pm2
I have a docker container that runs multiple python scripts with pm2, each one of them has its own .log file and I want to tail them separately in order to debug them easily. The problem is when I run docker exec -it mycontainer /bin/sh and tail -f scriptFile.log inside the directory where the file is located only shows the first lines and it freezes until hit ctl + c. The image I'm using is nikolaik/python-nodejs:python3.9-nodejs16-alpine from enter link description here
Also tried docker logs tail -f container /app/logfile.log
Here is the dockerfile
FROM nikolaik/python-nodejs:python3.9-nodejs16-alpine
WORKDIR /app
# Installing pm2
RUN npm install pm2 -g
# Create prod env variable
ENV PROD=true
COPY . .
# Installing lxml
RUN apk add --update --no-cache g++ gcc libxslt-dev
# Installing requirements
RUN pip install -r requirements.txt
CMD ["pm2-runtime", "start", "ecosystem.config.js"]
I'm trying to run a node app with xvfb-run, here is my Dockerfile
FROM node:lts-alpine
RUN apk --no-cache upgrade && apk add --no-cache chromium coreutils xvfb xvfb-run
ENV CHROME_BIN="/usr/bin/chromium-browser"\
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" \
UPLOAD_ENV="test"
WORKDIR /app
COPY package.json .
COPY .npmrc .
RUN npm install
COPY . .
# EXPOSE 9999
ENTRYPOINT xvfb-run -a npm run dev
I can successfully build the image, but when I run it with docker run, it gets stuck without any log
But when I open an interactive shell and run the ENTRYPOINT command, it works...
How do I fix it?
You should add --init to docker run, for example:
docker run --init --rm -it $IMAGE$ xvfb-run $COMMAND$
I'm trying to execute shell file that contains python script.
But, I don't know why i met the error like this
file directory structure
/home/kwstat/workplace/analysis/report_me
home
kwstat
workplace
analysis
report_me
report_me.sh
python_file
python_code.py
...
$docker exec -it test /bin/bash -c "source /home/kwstat/workplace/analysis/report_me/report_me.sh"
# Error
/home/kwstat/workplace/analysis/report_me/report_me.sh: line 30: source: /usr/local/bin/python: cannot execute binary file
I tried several things in Dockerfile, But same error occured.
# 1.CMD ["/bin/bash","-l","-c"]
CMD ["/bin/bash","-l","-c"]
# 2. CMD bin/bash
CMD bin/bash
#########My Dockerfile#############
FROM continuumio/miniconda3
# System packages
RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y subversion
WORKDIR /home/kwstat/workplace/analysis/report_me
COPY environments.yml /home/kwstat/workplace/analysis/report_me/environments.yml
RUN conda env create -f /home/kwstat/workplace/analysis/report_me/environments.yml
# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]
RUN echo "conda activate my_env" >> ~/.profile
# Activate the environment, and make sure it's activated:
#RUN echo "Make sure flask is installed:"
COPY requirements.txt /home/kwstat/me_report_dockerfile/requirements.txt
RUN pip install -r /home/kwstat/me_report_dockerfile/requirements.txt
WORKDIR /home/kwstat/workplace/analysis/report_me/python_file
COPY python_file/ /home/kwstat/workplace/analysis/report_me/python_file
WORKDIR /home/kwstat/workplace/analysis/report_me/
COPY report_me.sh ./report_me.sh
RUN chmod +x report_me.sh
CMD ["/bin/bash"]
please any help ~
my problem was from shell script.
Inside the shell set the coda env path
and all solved.
I'm trying to deploy a docker image on my rpi3+ (arm7). The entrypoint script work when run manually, but I cant manage to make it work directly in the dockerfile. I always get this error:
Permision denied : Unknow
Heres my docker.
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-bionic-arm32v7
WORKDIR /SenseAI.CollectionAgent
COPY /s .
USER root
CMD /bin/bash -c 'chmod +x /SenseAI.CollectionAgent/run.sh'
ENTRYPOINT ["/SenseAI.CollectionAgent/run.sh"]
The path of the file seems right.
I have tried so many different commands, but none worked.
The content of my run.sh is
#!/bin/bash
set -x #echo on
apt-get update
apt-get install libreadline-dev -y
chmod +x Gateway/SenseaiZ3Gateway
dotnet SenseAI.CollectionAgent.dll
but I think the error really comes from launching run.sh
Thank you !
you need to set the chmod command in RUN Directive:
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-bionic-arm32v7
WORKDIR /SenseAI.CollectionAgent
COPY /s .
USER root
RUN chmod +x /SenseAI.CollectionAgent/run.sh
ENTRYPOINT ["/SenseAI.CollectionAgent/run.sh"]