Reputation: 75
I use pipenv to start my application server and would like to start redis-server when the container spins up.
right now, I have to spin up a container and go inside of the container and run redis-server
to start redis. I want to start everything with docker-compose up
.
is there a way to do this ?
I have a docker-composer file like below
version: '3'
services:
api:
# docker run -d -p 8000:8000 data-tracker-backend pipenv run start
build: ./api
command: pipenv run start
image : data-tracker-backend
volumes:
- ./api:/api
expose:
- "8000"
Thank you
Upvotes: 2
Views: 9676
Reputation: 1013
You can create another service for redis and make the first service i.e api dependent on the redis service. Change your docker-compose.yml to something like this
version: '3'
services:
api:
build: ./api
command: pipenv run start
image : data-tracker-backend
volumes:
- ./api:/api
expose:
- "8000"
depends_on:
- redis-server
redis-server:
image: "redis:alpine"
command: redis-server
ports:
- "6379:6379"
Upvotes: 8