简体   繁体   中英

Error on building Dockerfile to Image

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?

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

在此处输入图片说明

Hope this helps.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM