2

I have the following Dockerfile. I'm trying to build it to an image, but somehow I receive the following error: ADD service /container/service ADD failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder005872257/service: no such file or directory at Step 6/9. I don't know why... Can anyone help me?

FROM osixia/light-baseimage:1.1.1
ARG LDAP_OPENLDAP_GID
ARG LDAP_OPENLDAP_UID

RUN if [ -z "${LDAP_OPENLDAP_GID}" ];  then groupadd -r openldap; else groupadd -r -g ${LDAP_OPENLDAP_GID} openldap; fi && if [ -z "${LDAP_OPENLDAP_UID}" ]; then useradd -r -g openldap openldap; else useradd -r -g openldap -u ${LDAP_OPENLDAP_UID} openldap; fi

RUN echo "path-include /usr/share/doc/krb5*" >> /etc/dpkg/dpkg.cfg.d/docker && apt-get -y update && /container/tool/add-service-available :ssl-tools \
        && LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ldap-utils \
libsasl2-modules \
libsasl2-modules-db \
libsasl2-modules-gssapi-mit \
libsasl2-modules-ldap \
libsasl2-modules-otp \
libsasl2-modules-sql \
openssl \
slapd \
krb5-kdc-ldap \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ADD service /container/service
RUN /container/tool/install-service
ADD environment /container/environment/99-default
EXPOSE 389 636

EDIT

After adding some ls commands in the Dockerfile I've seen the following line in logs:

Step 6/11 : RUN ls /container/
 ---> Running in 623dca399324
environment
service
service-available
tool
Removing intermediate container 623dca399324

 ---> 5f7fcb8a1857

Step 7/11 : RUN ls
 ---> Running in 7f3bd8662113
bin
boot
container
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
Removing intermediate container 7f3bd8662113

     ---> 99c17cefc572
Step 8/11 : ADD service /container/service
ADD failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder200387466/service: no such file or directory

Any idea how can I resolve this?

Dina Bogdan
  • 4,345
  • 5
  • 27
  • 56
  • try and delete or revise your `.dockerignore` file. It makes it throw this error sometimes because it ignored the directory Docker file build is needing in some cases. – Afolabi Olaoluwa Feb 27 '18 at 14:18

2 Answers2

1

it successfully build on my local machine.Can you delete the respective files or directories and try once. Also, check the permissions. Did you configure .dockerignore which will not allow to ADD those files. Or else try running with -f or --file command like,

$ docker build . -f Dockerfile

enter image description here

Hope this helps.

mohan08p
  • 5,002
  • 1
  • 28
  • 36
  • Unfortunately, this not works for me. How should I configure the .dockerignore file? – Dina Bogdan Feb 26 '18 at 20:07
  • @DinaBogdan: check this thread, https://stackoverflow.com/questions/25490911/how-do-you-add-items-to-dockerignore/44352134#44352134 But, it's not necessary that you have to create this... I think, still the problem is with the respective files(which are not found during the build)... – mohan08p Feb 27 '18 at 04:52
1

The error means it can't find the directory which mean it probably doesn't exist or you are doing it the wrong way.

One of the things you can do is to make directory and add service to it. Below is a snippet explanation that could teach or help you:

RUN mkdir /container/

Then ADD service to the directory you created. Thus

ADD service /container/service

This can only serve as what could help to put you to track. However I will advice @mohan08p answer above because that works for me.

Afolabi Olaoluwa
  • 1,898
  • 3
  • 16
  • 37
  • 1
    I've tried to create the container folder one step before adding the service to container, but the error message from log said that container folder already exists. Somehow, after removing the mkdir /container/ line, I've runned one more time the build and I've seen that right before adding the service to the container folder, the conainter it's removed, I've received the message: Removing intermediate container 7f3bd8662113. Any idea why? – Dina Bogdan Feb 27 '18 at 07:26
  • @DinaBogdan Paths in a `Dockerfile` are always relative to the the context directory. So I think if there is no `./container` in the context directory then this is the expected behaviour. Try and change it to `ADD service ./container/service` and see if it runs successfully so we can update the answer. – Afolabi Olaoluwa Feb 27 '18 at 14:02
  • Also, specifying Dockerfile using `-f` or `--file` flag as suggested by @mohan08p using `docker build . -f Dockerfile` or `docker build . -f path/to/Dockerfile` should work as well. – Afolabi Olaoluwa Feb 27 '18 at 14:05
  • Also check if the directory you are trying to ADD into is not ignored in `.dockerignore` file in your source code. – Afolabi Olaoluwa Feb 27 '18 at 14:07
  • I've tried to run the command with -f or --file, but didn't worked. I will try the rest of you suggestions. Thx – Dina Bogdan Feb 27 '18 at 14:10