This question has been posted before though I do not understand the answer here: use image-file in docker-compose file
I have an image.tar file in the root of my project (same folder as the docker-compose.yml file) and I want to include it in the services of my docker-compose.yml file so that I only have to run docker compose up for all containers and images to start including the local tar image.
Currently, I am running
docker load -i image.tar
and then running docker compose up though this does not start the image as per the screenshot below.
Even if it did - having to run this every time I want to start the container is something I want to avoid.
The local image is mt4rest.tar. As you will see from the below images - after loading the image and running docker compose up all the services from docker-compose.yml are in use though the mt4rest.tar is not.
How do I include the local tar file in docker-compose.yml so that I only have to run docker compose up and have all docker compose services start along with the local tar image?
docker-compose.yml
version: '3.9'
services:
api:
build:
context: ./backend/backend
dockerfile: Dockerfile
ports:
- "8000:8000"
command: >
sh -c "python3 manage.py makemigrations &&
python3 manage.py migrate &&
python3 manage.py wait_for_db &&
python3 manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=${DATABASE_NAME}
- DB_USER=${DATABASE_USER}
- DB_PASS=${DATABASE_PASSWORD}
depends_on:
- db
db:
image: postgres:14.1-alpine
environment:
- POSTGRES_DB=${DATABASE_NAME}
- POSTGRES_USER=${DATABASE_USER}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
volumes:
- pg_data:/var/lib/postgresql/data
redis:
image: redis:alpine
celery:
restart: always
build:
context: ./backend/backend
command: celery -A backend worker -l INFO
volumes:
- celery_data:/api
environment:
- DB_HOST=db
- DB_NAME=api
- DB_USER=${DATABASE_USER}
- DB_PASS=${DATABASE_PASSWORD}
depends_on:
- db
- redis
- api
volumes:
celery_data:
pg_data: