lstate error: no such file or directory while building Docker from a custom image with Docker build command

I have create a custom image for lamp stack with following files


Dockerfile was create with ENV, RUN, ADD and CMD command.

  • can't push or pull to a docker repo `Repository not found`
  • not able to start uwsgi as a service in docker
  • Docker container: MongoDb Insufficient free space for journal files
  • How to import a CSV inside a Docker container with Java 8?
  • What is the correct way to run an nginx docker container in OpenShift?
  • “Peer's certificate issuer has been marked as not trusted by the user” in Openshift3
  • Each application installed successfully, but stuck it at ADD command and check the given path which is correct.

    ADD /home/ktpl/nayan/MyLamp/supervisord.conf /etc/supervisor/supervisord.conf
    ADD /home/ktpl/nayan/MyLamp/apps.conf /etc/supervisor/conf.d/apps.conf
    ADD /home/ktpl/nayan/MyLamp/ /
    ADD /home/ktpl/nayan/MyLamp/ /

    Process is stuck at Add command.:

    lstat home/ktpl/nayan/lamp/supervisord.conf: no such file or directory

  • Data science workflow with large geospatial datasets
  • How to reuse the same volume in Docker when restarting a container?
  • How to ADD sibling directory to Docker image
  • How to set up autoscaling RabbitMQ Cluster AWS
  • How do I setup a docker image to dynamically pull app code from a repository?
  • How to import my db dump into mariadb on start?
  • 2 Solutions collect form web for “lstate error: no such file or directory while building Docker from a custom image with Docker build command”

    Docker builds always work relative to the context – i.e. the directory you pass in the docker build command. You cannot use absolute paths in ADD, you should be specifying the source file relative to the build context.

    For local files you should use COPY instead of ADD too, so your Dockerfile becomes:

    COPY ./supervisord.conf /etc/supervisor/supervisord.conf

    And then you build it from your MyLamp directory with docker build -t my-tag .

    ADD can be used to copy local files to image while building.

    Couple of things:

    • You are building an image using current directory
    • In your case, /home/ktpl/nayan/lamp is the valid directory
    • Not sure if you have a directory /home/ktpl/nayan/MyLamp exists and files present in there.

    As per the documentation of docker

    The path must be inside the context of the build; you cannot ADD ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

    If your files are in the same directory as you build image, then you may use below statements in Dockerfile

    ADD ./supervisord.conf /etc/supervisor/supervisord.conf
    ADD ./apps.conf /etc/supervisor/conf.d/apps.conf
    ADD ./ /
    ADD ./ /

    Of course, like it was mentioned in the other answer, COPY can also be used.

    Sample Dockerfile contents:

    FROM busybox
    ADD ./test.txt /test.txt
    CMD ls /

    You can building image and running it shows file being added in the below image.

    enter image description here

    If all the files and directories present and still you see this problem, then check .dockerignore has entry for the same.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.