Reputation: 123
i want to spin up a whole nodejs/mongodb environment with docker compose.i created a mongodump into radcupDevSample.json which i want to mongo restore i a new mongodb container. After this i want a new node container with my api linked to the mondodb container with the sample data.
i have the following files:
1. docker-compose.yml:
db:
image: mongo
ports:
- "27017:27017"`
mongo-importer:
build: .
web:
build: web
links:
- db
ports:
- "3000:3000"
volumes:
- ./src:/home/env
environment:
NODE_ENV: development
2. web Dockerfile:
FROM node
RUN apt-get update -y
RUN apt-get install -y git
RUN apt-get install -y vim
RUN git clone https://[email protected]/jdklfj /home/app
WORKDIR /home/app/src
RUN npm install
CMD "npm start"
EXPOSE 3000
3. "." dockerfile
FROM mongo
COPY radcupDevSample.json /radcupDevSample.json
CMD mongorestore -h db /radcupDevSample.json
I used this answer mentioned here: How do I seed a mongo database using docker-compose?
My problem is: if i try docker-compose up
i get this error:
docker-compose up
radcupbackend_db_1 is up-to-date
Building web
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/compose/compose/cli/main.py", line 54, in main
File "/compose/compose/cli/docopt_command.py", line 23, in sys_dispatch
File "/compose/compose/cli/docopt_command.py", line 26, in dispatch
File "/compose/compose/cli/main.py", line 171, in perform_command
File "/compose/compose/cli/main.py", line 587, in up
File "/compose/compose/project.py", line 313, in up
File "/compose/compose/service.py", line 404, in execute_convergence_plan
File "/compose/compose/service.py", line 303, in create_container
File "/compose/compose/service.py", line 326, in ensure_image_exists
File "/compose/compose/service.py", line 723, in build
File "/compose/venv/lib/python2.7/site-packages/docker/api/build.py", line 41, in build
TypeError: You must specify a directory to build in path
docker-compose returned -1
Have someone a "hint" why i get this errors ? Or maybe could someone help me out to set up this environment ?
Thank you!
PS. building the 2 Dockerfiles separately don't throw any error...
Upvotes: 3
Views: 3230
Reputation: 452
Looks like the docker is unable to find web/ directory from your current directory where you are running docker-compose up
Does your structure look like this?
anovil@ubuntu-anovil:~/tmp/docker-compose-mongo$ tree .
.
├── docker-compose.yml
├── Dockerfile
├── radcupDevSample.json
├── src
└── web
└── Dockerfile
2 directories, 4 files
anovil@ubuntu-anovil:~/tmp/docker-compose-mongo$
I created this kind of structure and then when I ran my build,
anovil@ubuntu-anovil:~/docker-compose-mongo$ docker-compose up
dockercomposemongo_db_1 is up-to-date
Starting dockercomposemongo_web_1
Building mongo-importer
Step 1 : FROM mongo
---> 94a166215fe3
...
In order to make sure everything is in order, I recommend you to run a docker-compose build --no-cache
first from the same directory, this will ensure that you start from a clean slate.
anovil@ubuntu-anovil:~/docker-compose-mongo$ docker-compose build --no-cache
db uses an image, skipping
Building web
Step 1 : FROM node
---> ac9b478bfbbd
...
And then run a docker-compose up
Please let me know how it went.
Upvotes: 2