Build Error: lstat composer.lock: no such file or directory


Running the Docker file found here ( getting the following error “Build Error: lstat composer.lock: no such file or directory”


That Dockerfile mentions both the composer.json file used to specify which dependencies to install, as well as the composer.lock file, which is used to make sure to install the same set of dependencies on different systems (same versions). You can get more information on the lock file at

However, if that file is not yet available (because you didn’t install dependencies locally yet), you’d need to create it or modify the Dockerfile.

To create the lockfile modify the Dockerfile and replace COPY composer.json composer.lock ./ with only COPY composer.json ./. The build the Docker image and create the lockfile by running the following commands

docker build --tag my-php-application .
docker run -it --rm -v $(pwd):/app my-php-application composer install

The second command mounts your current directory to the /app directory in the Docker container and then runs composer install to install the dependencies. Because composer install will write the lockfile and you mounted the directory to the Docker container you will end up with the composer.lock file in your local directory.

Once that’s done you can revert the Dockerfile to the version including the lockfile and are ready to go.