So today we learned about docker images and docker compose
docker images is when we build custom images that contain specific package
like maybe you want custom pip installation
and maintain your self.
There is TWO way to create image :
- Dockerfile
- Container Commit
But I just learned the first way.
1 – Create Dockerfile
FROM python:alpine3.17
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python", "app.py"]
2 – Build image
docker build . -t hello-python:1.0
Next, we learned about docker compose.
Docker compose when your webapp have mutiple microservices,
example app1 have :
- Database mysql
- Phpmyadmin to manage mysql
- Frontend using React
- Backend using Django
Then u need to use docker run to initialize all service, so to avoid these hassle, we use docker compose .
after we have images
We need file docker-compose.yml
services:
web:
build: .
ports:
- "8000:5000"
redis:
image: "redis:alpine"
Then to run
docker compose up