Category: Server

  • 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"
  • Volume resize on Linode Ubuntu VPS

    I recently had to upgrade the amount of storage on an external storage volume on a linode node and thought it would help to keep a note of the command to resize the volume on ubuntu

    resize2fs /dev/sdc

    where /dev/sdc is the attached volume

  • 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
  • Handy du commands in Linux

    Transfering files between servers and making sure directory sizes match has lead me down a path of exploring the du command in detail – heres some helpful commands I’ve been using to list directory sizes. I’ve been using ubuntu but should work in debian etc too.

    To list all top level directories

    du -h -d 1

    To list all directories that match a directory name

    du -hsc Name*

    this one lists top level where directory name stars with Name and the wildcard * at the end – Name, NameOne, NameTwo etc

    Another handy feature is adding sort in reverse order with human readable sizes by piping the output into the sort command

    du -hsc Name* | sort -hr

    also watching the directory sizes whilst transferring files is helpful!

    watch -n 10 du -h -d 1

    where the -n 10 is the amount of seconds between refreshes

  • Install Docker on Ubuntu 24.04

    Just a quick snippet to remind me quickly how to install docker on Ubuntu 24.04

    curl -fsSL https://get.docker.com -o get-docker.sh
    chmod a+x get-docker.sh
    ./get-docker.sh

  • CloudPanel Installation

    Install cloudpanel on a Ubuntu 24.04 LTS server

    ssh root@yourIpAddress
    
    apt update && apt -y upgrade && apt -y install curl wget sudo
    
    curl -sS https://installer.cloudpanel.io/ce/v2/install.sh -o install.sh; \
    echo "2aefee646f988877a31198e0d84ed30e2ef7a454857b606608a1f0b8eb6ec6b6 install.sh" | \
    sha256sum -c && sudo bash install.sh

    Once install access via

    https://yourIpAddress:8443

    Updated instructions can be found here:

    https://www.cloudpanel.io/docs/v2/getting-started/other/

  • Rclone Sync Command

    Sample of the rclone sync command thats setup to transfer 10 files at a time

    rclone sync --progress --multi-thread-streams=10 --transfers=10 /home/user/folder/ /mnt/ShareName/

    Another handy little flag is the check first flag which does all the checking first before starting transfers

    --check-first

    and always remember to dry run first

    --dry-run

  • FStab SMB Drives

    Simple snippet to remember how to add smb mounts to /etc/fstab

    mkdir /mnt/ShareName
    chmod 0755 /mnt/ShareName
    nano /etc/fstab
    //ipaddress/ShareName /mnt/ShareName cifs username=user,password=pass,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
    ctrl x to save
    mount -a

    To unmount the drive

    umount /mnt/ShareName

    Important note to never unmount all drives!

    umount -a