# Docker WORKDIR causing bad image

**URL:** <https://discuss.circleci.com/t/docker-workdir-causing-bad-image/10387>\
**Category:** Build Environment\
**Tags:** docker, make\
**Created:** [February 15, 2017, 6:41pm UTC](https://discuss.circleci.com/t/docker-workdir-causing-bad-image/10387 "2017-02-15T18:41:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxbeatty](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/maxbeatty/32/14718_2.png) [@maxbeatty](https://discuss.circleci.com/u/maxbeatty)\
**Post date:** [February 15, 2017, 6:41pm UTC](https://discuss.circleci.com/t/docker-workdir-causing-bad-image/10387/1 "2017-02-15T18:41:14Z")

</div>

I have 3 projects using very similar (almost exact) Dockerfile. Two build images just fine on CircleCI but the third project builds an image successfully but when you try to run it, this error message is logged:

```auto
starting container process caused "chdir to cwd (\"/src\") set in config.json failed: not a directory"

```

`/src` is from `WORKDIR` in the Dockerfile below. Building locally works fine and the other 2 projects using `WORKDIR` on CircleCI work fine. I’ve tried using `--rm=false` and a clean cache to no avail.

Here is the Dockerfile:

```auto
FROM alpine:3.4

RUN wget "s3.amazonaws.com/aws-cli/awscli-bundle.zip" -O "awscli-bundle.zip" && \
    unzip awscli-bundle.zip && \
    apk add --update groff less python ca-certificates && \
    rm /var/cache/apk/* && \
    ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
    rm awscli-bundle.zip && \
    rm -rf awscli-bundle

EXPOSE 4000

WORKDIR /src

COPY scripts/entrypoint.sh .
COPY go_binary_built_outside_docker .

CMD ["./entrypoint.sh"]

```

Here is our `circle.yml`:

```auto
machine:
  environment:
      GODIST: "go1.7.4.linux-amd64.tar.gz"
      PROJECT_GOPATH: "${HOME}/.go_workspace"
      PROJECT_PARENT_PATH: "${PROJECT_GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}"
      PROJECT_PATH: "${PROJECT_PARENT_PATH}/${CIRCLE_PROJECT_REPONAME}"
      GOPATH: "${GOPATH}:${PROJECT_GOPATH}"
  post:
      - mkdir -p download
      - test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
      - sudo rm -rf /usr/local/go
      - sudo tar -C /usr/local -xzf download/$GODIST
      - go version
  services:
      - docker

dependencies:
  override:
    - mkdir -p "${PROJECT_PARENT_PATH}"
    - rsync -avC "${HOME}/${CIRCLE_PROJECT_REPONAME}/" "${PROJECT_PATH}"
  post:
    - mkdir -p $GOPATH/bin
    - make install

test:
  override:
    - cd "${PROJECT_PATH}" && make test

deployment:
  prod:
    branch: master
    commands:
      - cd "${PROJECT_PATH}" && make deploy

```

Here is our relevant Makefile:

```auto
build:
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o repo .;
# https://circleci.com/docs/docker-btrfs-error/
ifdef CI
	docker build --rm=false -t org/repo:$(CIRCLE_SHA1) .
else
	docker build -t org/repo:$(CIRCLE_SHA1) .
endif

```

Happy to provide any other details. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:39am UTC](https://discuss.circleci.com/t/docker-workdir-causing-bad-image/10387/2 "2018-06-18T11:39:10Z")

</div>

Closed on June 18, 2018, 11:39am UTC


