Docker Builds are failing on CircleCI



Hi all,

I have an issue whereby my local Docker builds run fine, but on circle I get an error. The dockerfile looks like this:

FROM node:5

WORKDIR opt/app
ADD package.json .

RUN npm install
ADD . .


CMD ["npm", "start"]

The app in the container is a bog standard Hapi.js server - essentialy nothing more than the sample app, nothing special. Locally I build and deploy the container with no issues at all, using a makefile:

	# Build the docker image, using the 'latest' tag.
	docker build -t myproject/app:latest .

	# Login to the Docker Hub and push the image.
	docker push mproject/app:latest

As I would expect, as this is all standard stuff. However - running the make deploy command on CircleCI in my deployment step results in:

Digest: sha256:9da79fcba95ec76805a18b387aa2ff81927d2ebe0cd6c897cfdc2e80b8a91432
Status: Downloaded newer image for node:5
 ---> 319251e19588
Step 2 : WORKDIR opt/app
 ---> Running in 4f5f8bd1793c
 ---> 3c2e01e38161
Error removing intermediate container 4f5f8bd1793c: rmdriverfs: Driver btrfs failed to remove root filesystem 4f5f8bd1793c9c5cf1f7aef5391471b6a409e6a2c11e61cbf1ebdb9dc3de363e: Failed to destroy btrfs snapshot /var/lib/docker/btrfs/subvolumes for 4f5f8bd1793c9c5cf1f7aef5391471b6a409e6a2c11e61cbf1ebdb9dc3de363e: operation not permitted
Step 3 : ADD package.json .
 ---> 633e287145d2
Error removing intermediate container 4f5f8bd1793c: nosuchcontainer: no such id: 4f5f8bd1793c9c5cf1f7aef5391471b6a409e6a2c11e61cbf1ebdb9dc3de363e
Step 4 : RUN npm install
 ---> Running in 5fe2afdce5b0
Cannot mkdir: /opt/app is not a directory
make: *** [deploy] Error 1

make deploy returned exit code 2

Action failed: make deploy

Removing the WORKDIR (as the CicleCI build seems to struggle with it) fixes nothing (but actually breaks my project as it means my code runs in \ and attempts to watch system files which are adjacent).

Can anyone help? This is hugely limiting for me as I cannot deploy my containers! In case it makes a difference, here’s my circle.yml, I’ve tried ‘vanilla’ docker and a few of the versions available for CicleCI on S3:

    version: 5
   - sudo curl -L -o /usr/bin/docker ''
   - sudo chmod 0755 /usr/bin/docker
  - docker
    branch: master
      - make deploy

Thanks in advance!!!


Docker Error removing intermediate container

These aren’t actual errors, the issue, as you narrowed down, is the WORKDIR opt/app

It’s stating that you don’t have an opt/app folder in your project root, can you doublecheck that path is correct?


Hi @drazisil indeed, from reading on other issues the intermediate container issue should not actually cause any problems.

There’s no opt/app in my project root - all the WORKDIR command is saying to docker is essentially ‘from now on, do everything in that folder’, which means it creates the folder, then all of my subsequent ADD commands are adding relative to that folder and the PWD for the process is that folder.

This all works fine locally. However it was a very good idea to check this! Interestingly when I explicitly add a RUN mkdir -p /opt/app the problem goes away:

FROM node:5

# Build everything in the /opt/app folder.
RUN mkdir -p opt/app
WORKDIR opt/app

# Add our package definitions and build, supporting
# nice clean caching of the dependencies.
ADD package.json .
RUN npm install

# Now add the rest of our code...
ADD . .

# ...then expose the server port and start.
CMD ["npm", "start"]

This now works with no problems.

It seems that locally all is well, but on CircleCI the following statement from the Docker documentation:

If the WORKDIR doesn’t exist, it will be created even if it’s not used in any subsequent Dockerfile instruction.

Doesn’t hold true. Perhaps due to the version of Docker being used?

Anyway, for now forcing the manual creation of the folder works. Looking at other posts, docker instructions which change the filesystem seem to be problematic on CircleCI, I guess the WORKDIR make folder code is failing under the hood.

Thanks for your help!


Doesn’t hold true. Perhaps due to the version of Docker being used?


CircleCI’s default docker version is 1.9.1, and WORKDIR behaved differently back then: (specifically, the documentation is missing the bit about the auto-creation).

This behaviour was added (well, documented) in


@sldblog thanks or confirming my suspicions! Really appreciate you taking the time to help me clear up the mystery. Cheers all!


I ran into this issue this week, and feel very strange that if Dockerfile runs without any problem on my local box but can’t build in CircleCI.

I’ll add a mkdir then, but suggest that CircleCI upgrades docker version to solve this issue for the late comers.