INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / Thingiverse / RSS / GPG

Autocleaning docker registry

№ 10098 В разделе "Sysadmin" от June 25th, 2019,
В подшивках:

To remove old images (in my case images can’t be older 14 days) I used https://github.com/andrey-pohilko/registry-cli and included registry tools to collect garbage.

Make sure you run your registry with REGISTRY_STORAGE_DELETE_ENABLED=true

docker run -d -p 127.0.0.1:5000:5000 -e "REGISTRY_STORAGE_DELETE_ENABLED=true" --restart always \
  --name docker-images-registry \
  -v /srv/registry/data:/var/lib/registry \
  -v /srv/registry/users:/auth/htpasswd registry:2

Now you can delete images

docker run --rm --link docker-images-registry anoxis/registry-cli \
  -r http://docker-images-registry:5000 --delete --keep-by-hours 336 \
  --keep-tags-like latest --digest-method=GET

Ok, use garbage collector

docker stop docker-images-registry

docker run --rm -v /srv/registry/data:/var/lib/registry \
  -v /srv/registry/users:/auth/htpasswd registry:2 \
  bin/registry garbage-collect /etc/docker/registry/config.yml

docker start docker-images-registry

Well done! Take a donut from a shelf.

Нет комментариев »

Zabbix automatic discovery and monitoring Docker containers

№ 9617. В разделе " Sysadmin " от December 2nd, 2018

В подшивках: , ,

Cron inside your Docker image with python app

№ 9577 В разделе "Sysadmin" от November 25th, 2018,
В подшивках: ,

At first, create your cron file with usual crontab lines and name it mycrontab_lines

*/5 * * * * /app/cron_script.sh

Now create your cron_script.sh

#!/bin/bash
# load env variables
source /etc/profile
. ~/.profile

python3 /app/mycronapp.py

Ok, you ready now to create Dockerfile like this:

FROM python:3

# install cron service
RUN    apt-get ${APT_FLAGS_COMMON} update && \
    apt-get ${APT_FLAGS_PERSISTENT} -y install cron && \
    apt-get ${APT_FLAGS_COMMON} autoremove && \
    apt-get ${APT_FLAGS_COMMON} clean && \
    rm -rf /var/lib/apt/lists/*

# bla bla bla copy app.py
WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# install python app
COPY app.py .
COPY mycronapp.py .

# make cron
COPY mycrontab_lines .
COPY cron_script.sh .
RUN chmod 0755 run_previewer.sh
RUN chmod 0644 mycrontab_lines
RUN crontab mycrontab_lines

# start cron service before start blocking application
CMD service cron start && \
    python ./app.py

Build and run container.

Нет комментариев »

shroudBNC (sBNC) 1.3.9 in Docker

№ 9569 В разделе "Sysadmin" от November 23rd, 2018,
В подшивках:

Yes! This is legendary SBNC! Used repositories of Ubuntu 16.04 to get it and build this precious Docker image.

Place in /srv/docker/sbnc/home your predefined config files, it is a user’s home directory and stored in $HOME.

Sample config files:

$HOME/sbnc/sbnc.conf

system.users=vlad
system.port=9000
system.ip=0.0.0.0
system.md5=0

$HOME/sbnc/users/vlad.conf

user.password=myultrasecurepassword
user.server=irc.tomsk.net
user.realname=21h
user.port=6669
user.nick=vlad
user.admin=1
user.seen=1542914743
user.autobacklog=on
user.channels=#linux

Now you are ready to run it:

docker run -d --name sbnc \
    -v /srv/docker/sbnc/home:/var/lib/sbnc \
    -p 9000:9000 \
    --restart=always iam21h/sbnc

DO NOT FORGET TO SET RIGHT FILES PERMISSIONS ON CONFIG DIRECTORIES AND FILES!

Docker HUB https://hub.docker.com/r/iam21h/sbnc/
Source https://git.blindage.org/21h/docker-shroudBNC

Нет комментариев »

Backup MySQL в Docker

№ 9567 В разделе "Sysadmin" от November 22nd, 2018,
В подшивках: , ,

Backup

docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

Restore

cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

Нет комментариев »

Яндекс.Метрика

Fortune cookie: Today's spam: Be congers go camargo