INT 21h

Hi, I am Vladimir Smagin, SysAdmin. Telegram Email GPG / Микроблог

Cron inside your Docker image with python app

№ 9577 В разделе "Администрирование" от 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.

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

Nginx unitd in Docker, upload configuration and additional PHP module during image building

№ 9575 В разделе "Администрирование" от November 25th, 2018,

Yes, I know, complete documentation about containerization unitd with predefined config is absent, found examples just uploads config after container start, but not during build. Here’s my own Dockerfile with unitd, php, php-mysql module and uploading project’s configuration during image building.

FROM nginx/unit:1.6-php7.0

LABEL maintainer="21h@blindage.org"
LABEL description="More information here https://blindage.org/?p=9575"

RUN    apt-get ${APT_FLAGS_COMMON} update && \
    apt-get ${APT_FLAGS_PERSISTENT} -y install php7.0-mysql && \
    apt-get ${APT_FLAGS_COMMON} autoremove && \
    apt-get ${APT_FLAGS_COMMON} clean && \
    rm -rf /var/lib/apt/lists/*

COPY config.json /state/new_config.json

WORKDIR /www

COPY index.php .

RUN mkdir preview
RUN chown -R www-data:www-data /www

# upload config to unitd and die
RUN unitd --state /state --pid /tmp/unitd.pid && \
    curl -s -X PUT -d @/state/new_config.json \
         --unix-socket /run/control.unit.sock \
         http://localhost/config/ && \
    kill -9 $(cat /tmp/unitd.pid)

EXPOSE 80

# now container ready to start with predefined config
CMD ["unitd", "--no-daemon", "--state", "/state"]

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

shroudBNC (sBNC) 1.3.9 in Docker

№ 9569 В разделе "Администрирование" от 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 В разделе "Администрирование" от 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

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

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

# 2018-11-26 09:15:41

Обнаружил в kubedb код google analytics UA-62096468-20, слежка включена по умолчанию.

# 2018-11-24 23:30:12

Несложно смог контейнеризовать nginx unit с предзагрузкой конфигурации перед стартом контейнера blindage.org/?p=9575


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

Fortune cookie: "Is it just me, or does anyone else read `bible humpers' every time someone writes `bible thumpers?' -- Joel M. Snyder, jms@mis.arizona.edu