INT 21h

Hi, I am Vladimir Smagin, SysAdmin, DevOps and barely good guy. Telegram Email / GIT / Микроблог / Thingiverse / GPG

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

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

Postgres backup to FTP from Docker or directly, see examples

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

You can easily dump your Postgresql database from Docker container or directly and you have 2 ways to do it. First variant more dangerous, depends on internet connection, but not requires a lot of disk space. Second variant more stable, but if free space suddenly is out your backup will be failed. You can add error checking and reporting to Zabbix like here.

Variant 1: stream backing up file to FTP (directly)

#!/bin/bash
source /etc/profile
weekday=$(date '+%w')
pg_dump postgresql://pguser:pgpassword@mydatabase.server.com:5433/database | gzip | curl -u ftplogin:ftppassword \
ftp://backup-ftp.server.com/postgres-backups/$weekday/db_backup.sql.gz --ftp-create-dirs -T -

Variant 2: dump to local host, upload and delete local file (from Docker)

#!/bin/bash
source /etc/profile

db_user="postgres"
db_pass="lkfgjs4573234"
db_host="127.0.0.1"
db_port="5432"
db_name="my_precious_db"

ftp_user="useruseruser"
ftp_pass="klksdjfa;lkjdf"
ftp_serv="ftp.server.ru"

weekday=$(date '+%w') # 7 days history
history=${weekday}

docker exec -it pg-slave-server su -c "pg_dump postgresql://${db_user}:${db_pass}@${db_host}:${db_port}/${db_name}" \
    postgres |gzip -7 > /tmp/db_backup_${db_name}_${history}.sql.gz
curl --upload-file /tmp/db_backup_${db_name}_${history}.sql.gz ftp://${ftp_user}:${ftp_pass}@${ftp_serv}/
rm -f /tmp/db_backup_${db_name}_${history}.sql.gz

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

Микроблог перейти

# 2019-12-23 09:14:01

Очень интересная концепция, docker-compose для kubernetes kompose.io/ #devops #kubernetes #docker

# 2019-12-16 17:21:18

Надо будет почитать для общего развития как оживить кластер в случае проеба сертов habr.com/ru/company/southbridg #kubernetes #devops

# 2019-12-12 17:33:46

js bootstrap с интерфейсом как в DOS github.com/kristopolous/BOOTST


© Vladimir Smagin, 2005-2019. Копирование материалов без разрешения запрещено. GPG DA4CD0F5E222EA727D6A40C413BCE12E5618F071 *
Яндекс.Метрика

Fortune cookie: The most pressing issue facing women today is finding a contraceptive jelly that smells like a fresh fruit salad.