Docker Community Forums

Share and learn in the Docker community.

Entrypoint Problems


(Wes Z) #1

I am having Entrypoint problems and I’m not sure what is happening.
On my master-node I created a directory at /boinc/ and in that directory I have Dockerfile and boinc_start.sh
Dockerfile is basic:

FROM ubuntu:latest
LABEL Maintainer="Me odroid@odroid.com"
LABEL description=“Boinc3 MC1-2 image”

Install BOINC

RUN apt-get update && apt-get install -y boinc-client && apt-get clean && rm -rf /var/lib/apt/lists/*

Set working directory

WORKDIR /var/lib/boinc-client

Make port 80 available

EXPOSE 80

Create an entry point

ENTRYPOINT /boinc/boinc_start.sh

Run BOINC by default. Expects env vars for url and account key

CMD /etc/init.d/boinc-client start; sleep 5; /usr/bin/boinccmd --project_attach ${boincurl} ${boinckey}; tail -f /var/lib/boinc-client/std*.txt

and boinc_start.sh is:

#!/bin/bash
mkdir -p /dev/input/mice
exec “$@”

I have chmod +x /boinc/boinc_start.sh

I build the file with:

cd /boinc/
docker build -t additude/boinc3 .

image builds successfully

I push the image:

docker push additude/boinc3

Then I go to a different node and I:

cd /
mkdir /boinc/
cd /boinc/
nano boinc_start.sh
#!/bin/bash
mkdir -p /dev/input/mice
exec "$@"
nano write and save
chmod +x /boinc/boinc_start.sh
mkdir /boinc/boinc_persist

then from the node, still in the /boinc/ directory

docker run -it -d --name Seti-3 -h node2-2 -v /boinc/boinc_persist:/var/lib/boinc-client --log-opt max-size=10m --log-opt max-file=3 --restart=always -e “boincurl=setiathome.berkeley.edu” -e “boinckey=xxxxxxxxxxxxxxxxx” additude/boinc3

Everything goes fine, pulls the image from additude/boinc3.

I check the logs docker logs Seti-3 and:

root@node2-2:/boinc# docker logs Seti-3
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found
/bin/sh: 1: /bin/sh: /boinc/boinc_start.sh: not found

I am out of ideas at this point. I have tried several things and read and read.
I can’t make it work. I need some help.
Thanks.


(Sam) #2

but… boinc_start.sh is not IN the container or accessible by the container

Then I go to a different node and I:
cd /
mkdir /boinc/ <---- that is on the host
cd /boinc/
nano boinc_start.sh   <--- this is on the host
#!/bin/bash
mkdir -p /dev/input/mice
exec "$@"
nano write and save
chmod +x /boinc/boinc_start.sh
mkdir /boinc/boinc_persist

you shared boinc_persist with the container

-v /boinc/boinc_persist:/var/lib/boinc-client

but not boinc itself.

and /boinc doesn’t exist IN the container…
you didn’t create it in the Dockerfile
and didn’t map it from the host into the container on docker run


(Wes Z) #3

Thanks,
That all makes sense to me.
But how do I successfully get boinc_start.sh into the container where it can be found?

ADD or COPY in the Dockerfile?

maybe it should be located in a directory above where I do the docker build?

I can’t figure it out.


(Sam) #4

right…

create it on the host, in the same folder as the Dockerfile, make it executable
then add this to the Dockerfile
there are comment chars in front of the text below, don’t know hot fix this forums markup

create the folder

run mkdir /boinc

copy the command to the image

copy ./boinc_start.sh /boinc


(Wes Z) #5

Thanks. Every Example I looked at did not have this bit of info.

Is this something that needs to be done for every entrypoint file?


(Sam) #6

well, the files need to be INSIDE the container somewhere…

the doc shows how to get files in with add or copy commands.

the container is a closed environment, except for limited capabilities, -v or -e (environment) or parms beyond the image name.


(Wes Z) #7

ok… I’m just looking too hard…

But I also tried in the Dockerfile:
RUN mkdir /dev/input/mice

and that didn’t work… I thought it would…


(Sam) #8

well /dev/ is a controlled folder… i don’t know that you can modify it


(Wes Z) #9

after the container is running, when I don’t use the entrypoint file I can do docker exec mkdir -p /dev/input/mice and it creates the directory…

that’s why I felt RUN mkdir -p /dev/input/mice would work…


(Sam) #10

ok, i don’t ever fiddle with /dev, so I don’t know the rules


(Wes Z) #11

Thanks for your help. !!


(Raj Chaudhuri) #12

Has the problem been solved? If not, here is what you need to do.

First, create a directory from which you will build the docker image (lets call it /boinc). In this directory, ensure that there are two files: boinc_start.sh and the Dockerfile. The contents of these files should be as follows:

boinc_start.sh:

#!/bin/bash
mkdir -p /dev/input/mice
exec "$@"

Dockerfile:

FROM ubuntu:latest
LABEL Maintainer="Me odroid@odroid.com"
LABEL description=“Boinc3 MC1-2 image”

# Install BOINC
RUN apt-get update && apt-get install -y boinc-client && apt-get clean

# ADDED BY RAJ: Copy entrypoint shell script
COPY boinc_start.sh /boinc/boinc_start.sh

# ADDED BY RAJ: Make it executable
RUN chmod +x /boinc/boinc_start.sh

# Set working directory
WORKDIR /var/lib/boinc-client

# Make port 80 available
EXPOSE 80

# Create an entry point
ENTRYPOINT /boinc/boinc_start.sh

# Run BOINC by default. Expects env vars for url and account key
CMD /etc/init.d/boinc-client start; sleep 5; \
            /usr/bin/boinccmd --project_attach ${boincurl} ${boinckey}; \
            tail -f /var/lib/boinc-client/std*.txt

Note the additions I have made to your Dockerfile. These two commands will copy the boinc_start.sh script into the image and make it executable, as part of building the image.

Now, build the image with:

cd /boinc
docker build -t additude/boinc3 .

And push it with:

docker push additude/boinc3

From this point on, you need only the image on any node. No need to create any directories or files, or anything else. Just create and run a container with:

docker run -it -d --name Seti-3 -h node2-2 
                  -e “boincurl=setiathome.berkeley.edu” 
                  -e “boinckey=xxxxxxxxxxxxxxxxx” 
                  additude/boinc3

If you want to persist the logs etc. beyond the lifetime of the container, use -v.


(Wes Z) #13

Thanks. I have it working now !!