Devops Learning Day – 3

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 :

  1. Dockerfile
  2. 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 :

  1. Database mysql
  2. Phpmyadmin to manage mysql
  3. Frontend using React
  4. 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
Share the Post:

Related Posts