`make docker_up` is throwing `external volume "<project_name>_dbdata" not found`
terrynguyen255 opened this issue · 1 comments
terrynguyen255 commented
Describe the bug
make docker_up
is throwing external volume "<project_name>_dbdata" not found
docker-compose.yml
version: '3.5'
services:
db:
image: "postgres:alpine"
environment:
- POSTGRES_USER=myproject
- POSTGRES_PASSWORD=password
- POSTGRES_DB=myproject
ports:
- "5432"
volumes:
- dbdata:/var/lib/postgresql/data:delegated
broker:
image: "rabbitmq:alpine"
result:
image: "redis:alpine"
frontend:
build:
dockerfile: frontend/Dockerfile
context: .
volumes:
- .:/app/
- /app/node_modules
ports:
- "3000:3000"
backend:
build:
dockerfile: backend/Dockerfile
context: .
ports:
- "8000:8000"
volumes:
- ./:/home/user/app/
env_file: backend/.env
depends_on:
- db
- broker
- result
- frontend
celery:
build:
dockerfile: backend/Dockerfile
context: .
command: python manage.py celery
volumes:
- ./:/home/user/app/
env_file: backend/.env
depends_on:
- db
- broker
- result
mailhog: # service for faking a SMTP server
image: mailhog/mailhog
ports:
- '1025:1025' # smtp server
- '8025:8025' # web ui
volumes:
dbdata:
name: myproject_dbdata
external: true
Makefile
SHELL := /bin/bash # Use bash syntax
ARG := $(word 2, $(MAKECMDGOALS) )
clean:
@find . -name "*.pyc" -exec rm -rf {} \;
@find . -name "__pycache__" -delete
test:
poetry run backend/manage.py test backend/ $(ARG) --parallel --keepdb
test_reset:
poetry run backend/manage.py test backend/ $(ARG) --parallel
backend_format:
black backend
# Commands for Docker version
docker_setup:
docker volume create myproject_dbdata
docker-compose build --no-cache backend
docker-compose run frontend npm install
docker_test:
docker-compose run backend python manage.py test $(ARG) --parallel --keepdb
docker_test_reset:
docker-compose run backend python manage.py test $(ARG) --parallel
docker_up:
docker-compose up -d
docker_update_dependencies:
docker-compose down
docker-compose up -d --build
docker_down:
docker-compose down
docker_logs:
docker-compose logs -f $(ARG)
docker_makemigrations:
docker-compose run --rm backend python manage.py makemigrations
docker_migrate:
docker-compose run --rm backend python manage.py migrate
To Reproduce
Steps to reproduce the behavior:
- Init repo
django-admin startproject myproject --extension py,json,yml,yaml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip
- Start docker compose
make docker_up
- See error
Expected behavior
The services should be started successfully
Screenshots
Logs
>>> make docker_up
docker-compose up -d
[+] Running 37/11
✔ broker 10 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 19.5s
✔ mailhog 7 layers [⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 12.5s
✔ result 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 11.2s
✔ db 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 17.0s
[+] Building 113.8s (39/39) FINISHED docker:desktop-linux
=> [celery internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 868B 0.0s
=> [celery internal] load .dockerignore 0.0s
=> => transferring context: 71B 0.0s
=> [frontend internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 162B 0.0s
=> [frontend internal] load .dockerignore 0.0s
=> => transferring context: 71B 0.0s
=> [backend internal] load metadata for docker.io/library/python:3.12-slim 5.4s
=> [frontend internal] load metadata for docker.io/library/node:18-alpine 4.0s
=> [frontend auth] library/node:pull token for registry-1.docker.io 0.0s
=> [celery auth] library/python:pull token for registry-1.docker.io 0.0s
=> [frontend 1/5] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2 4.4s
=> => resolve docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2 0.1s
=> => sha256:eb7895eb72c1a145d166631d5a81c61bffd747783c52e8a1de9fa0e7d5871817 39.98MB / 39.98MB 1.4s
=> => sha256:7049a133eb54d652049fa44657d24cef7298dc371ffab6e27f5cd5e53e62159f 2.34MB / 2.34MB 0.6s
=> => sha256:90577567f13c6046278cbfa4a557cb5a19ed5f9c281ab540e84ddd8f74c71922 445B / 445B 0.4s
=> => sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2 1.43kB / 1.43kB 0.0s
=> => sha256:91f3cd192c9f1a1a907b8f53bb8cf737557e6c1bb9dc499a725e48ba6ced58fd 1.16kB / 1.16kB 0.0s
=> => sha256:7e24f77d89cc2edd3dd6963dd95bfde2dd4fc72e242b060ca583f7d93bc87efe 7.15kB / 7.15kB 0.0s
=> => extracting sha256:eb7895eb72c1a145d166631d5a81c61bffd747783c52e8a1de9fa0e7d5871817 2.4s
=> => extracting sha256:7049a133eb54d652049fa44657d24cef7298dc371ffab6e27f5cd5e53e62159f 0.1s
=> => extracting sha256:90577567f13c6046278cbfa4a557cb5a19ed5f9c281ab540e84ddd8f74c71922 0.0s
=> [frontend internal] load build context 0.1s
=> => transferring context: 235.81kB 0.0s
=> [backend 1/11] FROM docker.io/library/python:3.12-slim@sha256:123229cfb27c384ee1fcc15aec660ad280a09121b7893377e80ae1b2e72cf942 7.3s
=> => resolve docker.io/library/python:3.12-slim@sha256:123229cfb27c384ee1fcc15aec660ad280a09121b7893377e80ae1b2e72cf942 0.0s
=> => sha256:dca6251a5e4323c4e19768574d5364122e75b65f4582a0197fdece71631ea028 6.73kB / 6.73kB 0.0s
=> => sha256:123229cfb27c384ee1fcc15aec660ad280a09121b7893377e80ae1b2e72cf942 1.65kB / 1.65kB 0.0s
=> => sha256:406ccb55df816ecde3060f14d4a5955bb1fd961f9ef0262ee4436ef5f6a50295 1.37kB / 1.37kB 0.0s
=> => sha256:2c6d21737d8318aa15c4cc838475029a5efc36c0429e3d8da80d97d0b96d9aaf 29.18MB / 29.18MB 3.3s
=> => sha256:eed0175a0a2c6ea04c0688918deec0baaf3cc4ee3fd31d69088883d577408e52 3.33MB / 3.33MB 1.0s
=> => sha256:76e4e801d3dc33f0b59fd0e41f97d9a9490139d77601df9bc94460f3003272e1 11.94MB / 11.94MB 2.2s
=> => sha256:367716153c5ac9de6d4d0106a501cab2818bf1517fd68b2df4c501ce50162866 245B / 245B 2.4s
=> => sha256:a476c7a536924dfdd890357d981f59806bb94a860f58faa8b79fc24d522aeaf1 2.96MB / 2.96MB 3.0s
=> => extracting sha256:2c6d21737d8318aa15c4cc838475029a5efc36c0429e3d8da80d97d0b96d9aaf 2.6s
=> => extracting sha256:eed0175a0a2c6ea04c0688918deec0baaf3cc4ee3fd31d69088883d577408e52 0.3s
=> => extracting sha256:76e4e801d3dc33f0b59fd0e41f97d9a9490139d77601df9bc94460f3003272e1 0.6s
=> => extracting sha256:367716153c5ac9de6d4d0106a501cab2818bf1517fd68b2df4c501ce50162866 0.0s
=> => extracting sha256:a476c7a536924dfdd890357d981f59806bb94a860f58faa8b79fc24d522aeaf1 0.2s
=> [celery internal] load build context 0.0s
=> => transferring context: 28.41kB 0.0s
=> [frontend 2/5] WORKDIR /app/ 0.4s
=> [frontend 3/5] ADD package.json /app/package.json 0.1s
=> [frontend 4/5] RUN npm install 101.5s
=> CACHED [backend 2/11] RUN groupadd user && useradd --create-home --home-dir /home/user -g user user 0.4s
=> CACHED [backend 3/11] RUN apt-get update && apt-get install python3-dev gcc build-essential libpq-dev -y 16.3s
=> CACHED [backend 4/11] RUN pip install "poetry==1.7.1" 8.7s
=> [celery 5/11] COPY pyproject.toml /home/user/app/ 0.0s
=> [celery 6/11] COPY *poetry.lock /home/user/app/ 0.0s
=> [celery 7/11] WORKDIR /home/user/app/ 0.0s
=> [celery 8/11] RUN poetry config virtualenvs.create false 0.4s
=> [celery 9/11] RUN poetry install --with dev --no-root --no-interaction --no-ansi 34.7s
=> [celery 10/11] WORKDIR /home/user/app/backend 0.0s
=> [celery 11/11] COPY backend/ /home/user/app/backend 0.0s
=> [celery] exporting to image 1.0s
=> => exporting layers 1.0s
=> => writing image sha256:c7665ef1e68961a82f34dc74c8cdc470a79989423ac9515736d56340b06bee52 0.0s
=> => naming to docker.io/library/myproject-celery 0.0s
=> [frontend 5/5] ADD . /app/ 0.0s
=> [frontend] exporting to image 2.1s
=> => exporting layers 2.1s
=> => writing image sha256:40d3977ad068cf7edf0cacd045f6444f226d31356a3198d76c8265fa1268b5d2 0.0s
=> => naming to docker.io/library/myproject-frontend 0.0s
=> [backend internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 868B 0.0s
=> [backend internal] load .dockerignore 0.0s
=> => transferring context: 71B 0.0s
=> [backend internal] load build context 0.0s
=> => transferring context: 2.44kB 0.0s
=> CACHED [backend 5/11] COPY pyproject.toml /home/user/app/ 0.0s
=> CACHED [backend 6/11] COPY *poetry.lock /home/user/app/ 0.0s
=> CACHED [backend 7/11] WORKDIR /home/user/app/ 0.0s
=> CACHED [backend 8/11] RUN poetry config virtualenvs.create false 0.0s
=> CACHED [backend 9/11] RUN poetry install --with dev --no-root --no-interaction --no-ansi 0.0s
=> CACHED [backend 10/11] WORKDIR /home/user/app/backend 0.0s
=> CACHED [backend 11/11] COPY backend/ /home/user/app/backend 0.0s
=> [backend] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:8869397f4e9da02dca2d2a1aa5d40746c90057cf63e2e536f3db2fea268088fb 0.0s
=> => naming to docker.io/library/myproject-backend 0.0s
[+] Running 1/1
✔ Network myproject_default Created 0.0s
external volume "myproject_dbdata" not found
make: *** [docker_up] Error 1
Desktop (please complete the following information):
- Device: Mac mini M1
- OS: MacOS Ventura 13.3.1
terrynguyen255 commented
My bad. I init-ed the repo incorrectly.