# Error while executing Docker in Docker

**URL:** <https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046>\
**Category:** Build Environment\
**Tags:** docker, circle-yml\
**Created:** [September 11, 2018, 3:57pm UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046 "2018-09-11T15:57:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemanth22](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/hemanth22/32/12802_2.png) [@hemanth22](https://discuss.circleci.com/u/hemanth22)\
**Post date:** [September 11, 2018, 3:57pm UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046/1 "2018-09-11T15:57:49Z")

</div>

Hello team,

I have written below configuration to test in Circle CI.

```
version: 2
jobs:
  build:
    working_directory: /app
    docker:
      #- image:18.06.0-ce-git
      - image: docker:17.05.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py-pip=9.0.0-r1
            apk --no-cache add curl
            pip install wget
            pip install \
              docker-compose==1.12.0 \
              awscli==1.11.76
      - run: echo "Pulling docker's"
      - run: docker pull java:7
      - run: docker pull groovy
      - run: echo "Docker pull complete."
      - run: docker run --rm -v"$PWD":/usr/src/myapp -w /usr/src/myapp java:7 javac -d . Add.java
      - run: docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy groovy AddTests.groovy

```

But is throwing below error.

```
#!/bin/sh -eo pipefail docker run --rm -v"$PWD":/usr/src/myapp -w /usr/src/myapp java:7 javac Add.java

javac: file not found: Add.java Usage: javac &lt;options&gt; &lt;source files&gt; use -help for a list of possible options Exited with code 2

```

Can please check and advice what is wrong in the code. and why it has thrown error.

Thanks,  
Hemanth.

---

<div class="post-metadata">

**Author:** ![hemanth22](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/hemanth22/32/12802_2.png) [@hemanth22](https://discuss.circleci.com/u/hemanth22)\
**Post date:** [September 12, 2018, 2:08am UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046/2 "2018-09-12T02:08:24Z")

</div>

I have tested same command in play with docker.

I could see result is good .

**Playwithdocker result**

```
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp java:7 javac -d . Add.java
[node1] (local) root@192.168.0.18 ~/GroovyLearning
$ ls -la Ad
Add.class Add.java AddTests.groovy
[node1] (local) root@192.168.0.18 ~/GroovyLearning
$ docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy groovy AddTests.groovy
.
Time: 0.081

OK (1 test)

```

Then accordingly i have updated in circle ci configuration, even though it is thowing error.  
Can you please have a check.

Thanks,  
Hemanth.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 12, 2018, 9:52am UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046/3 "2018-09-12T09:52:35Z")

</div>

There’s a couple of things:

- Your first `-v` volume statement is missing a space after the switch, so I wonder if this might be a syntax error
- But, more importantly, on-host volumes don’t work in CircleCI. That’s because CircleCI intervenes in your Docker system to spin containers up on remote machines, and volumes don’t work across LAN connections. Search for “Docker volume” in this forum to see plenty of info about this (it happened to me too).

You can solve this in several ways:

- Build your own Docker image that inherits from `java:7` or `groovy` and copies in the files they need
- If you need more than one container to communicate, run containers inside Docker Compose

---

<div class="post-metadata">

**Author:** ![hemanth22](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/hemanth22/32/12802_2.png) [@hemanth22](https://discuss.circleci.com/u/hemanth22)\
**Post date:** [October 2, 2018, 12:53pm UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046/4 "2018-10-02T12:53:57Z")

</div>

Thank you @halfer.

When i have changed script as below, it is working fine.

```
version: 2
jobs:
  build:
    docker:
      #- image:18.06.0-ce-git
      - image: circleci/openjdk:8-jdk-browsers
    steps:
      - checkout
      - run:
          name: Installing Groovy.
          command: 'sudo apt-get install groovy'
      - run:
          name: Creating InsufficientFundsException.
          command: 'groovyc InsufficientFundsException.groovy'
      - run:
          name: Creating InterestRateService class.
          command: 'groovyc InterestRateService.groovy'
      - run:
          name: Executing Groovy test case.
          command: 'groovy BankAccountTests.groovy' 

```

Regards,  
Hemanth.

---

<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:** [October 12, 2018, 12:54pm UTC](https://discuss.circleci.com/t/error-while-executing-docker-in-docker/25046/5 "2018-10-12T12:54:00Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
