Category: Docker

  • Log rotation on docker compose

    To setup log rotation on docker compose simply add this

    logging:
      driver: "json-file"
      options:
        max-size: "1k"
        max-file: "3"

    so example docker-compose.yml file

    database:
      image: postgres:14.5-alpine
      restart: always
      ports:
        - "5432:5432"
      environment:
        POSTGRES_USER: user
      volumes:
        - ./data:/var/lib/postgresql/data:rw
      logging:
        driver: "json-file"
        options:
          max-size: "1k"
          max-file: "3"
  • Private Docker Registry

    I’ve recently started using a private docker registry for some docker images i’ve been using for certain projects that require special setup.

    To create the image

    docker build -t docker.example.com/directory/image:tag .

    Then I find the ID of the image using

    docker image ls

    Then when i’ve got the image ID I can tag the image

    docker tag 12345678 docker.example.com/directory/image:tag

    After that I can then push to the repository

    docker push docker.example.com/directory/image:tag