Dockerfile RUN Shellscript error while running if

Asked

Viewed 248 times

-1

I’m having a problem building on the dockerfile where I need to run a Shellscript so that I can insert a master word into it and it only contains the verification of a folder if it exists or not and if it does not display an echo to me stating that it does not exist. However it does not run this shellscript there is some way for me to get around this problem.

Operating system used : Windows Home Single

Emulated with the Docker Toolbox

Dockerfile

FROM centos
USER root
WORKDIR /home/app
COPY . /home/app
RUN apt-get update
RUN apt-get -y install nodejs
RUN sh install.sh

install sh.

if [ -f "data/global/workspaces.json" ]; then
    sed -i 's/"tp": \[\]/"tp": ["master"]/g' data/global/workspaces.json
else 
    echo "Erro: File ./data/global/workspaces.json not found!"
fi

1 answer

0

Try giving permission to run the file:

FROM centos
USER root
WORKDIR /home/app
COPY .* /home/app
RUN apt-get update
RUN apt-get -y install nodejs
RUN chmod +x install.sh  <<<<<<=
RUN sh install.sh
  • Hello Ronald, I’ve actually tried to apply chmod 777 to give permission but I believe there is some problem with Docker Tools on Windows because I’m running it on the company’s notebook and it always displayed a syntax error where the close is missing fi and the system is Windows Home Single, but when running it on a VM (with Ubuntu) it shows no error at all, I wonder if there is some way to get around this problem on my company laptop some permission in Tools, bash problem or something similar .

  • Dude... I don’t see the point, because Docker Toolbox is also a vm, only in this case, if you’re trying to mount from a windows directory, you’re doing it wrong because there is no conversion from CRLF to LF.

  • I suggest you go up two containers in Toolbox, like: A samba server container, in which you expose its port and then it is available to your windows machine, if I am not mistaken in ip 192.168.99.100 and so you mount this smb server in your windows, and thus work with their artifacts on VSCODE. The other container, would be a development environment where vc would put your stuff, in which, the volume that is mounted on the samba server is mounted in this container in /root

  • Ronald is probably with CRLF for LF even as you had commented, as I am cloning the git files and asking Docker to copy from my machine to the dockerfile image where he has problems running the shellscript but creating one. sh inside the image the same comes to work . Another alternative was to just download the dockerfile and insert the git installation and clone it into the image build in Docker

Browser other questions tagged

You are not signed in. Login or sign up in order to post.