(Ubuntu host in this example, but others should be similar)
docker run -d -v $(pwd)/redis.conf:/usr/local/etc/redis/redis.conf \ -v /data/redis:/data -p 6379:6379 \ --restart="always" \ --name myredis redis:3.0.3 redis-server /usr/local/etc/redis/redis.conf
sudo mkdir /data/redis && sudo chown ubuntu:docker $_ && sudo chmod g+w $_
echo never > /sys/kernel/mm/transparent_hugepage/enabled
ufw allow in on eth1 to any port 6379 proto tcp
FROM redis:3.0.3 COPY ./redis.conf /usr/local/etc/redis/redis.conf
A lot of minimal Debian distros don’t have the `ps` process status app by default. There are times it’s useful when you want to inspect a container from the inside, so add:
`apt-get install -y procps`
to your build or manually install it after. Adds about 1MB to your environment.
Pretty cool, a PHP 7.0 (RC4) with Apache environment on Mac from scratch in a few minutes via Docker container:
Includes installation for minimal requirements to support Yii 2.0
Uses Vagrant + VirtualBox on Mac (or similar) or instead you can use any existing Docker host.
I needed to extract comments from some files to use for documentation and settled on the below two regex flavors (which you use depends on the tool / programming language). Requirement was to match on the whole document as many times as comments appeared and only match the text and comments in case of mixed code and comments on one line.
You could extend this further by adding tokens to only fetch certain comments.
First version is for gnu-grep that accepts the “global” and “single-line” pcre (Perl Compatible Regular Expressions) modifiers:
1 2 3 4 5 6 7 8
\/ matches the character / literally \* matches the character * literally .*? matches any character Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [lazy] \* matches the character * literally \/ matches the character / literally g modifier: global. All matches (don't return on first match) s modifier: single line. Dot matches newline characters
Second is for cases you can’t use the prior, like some terminal apps:
From the command line, use:
pcregrep -M -o "\/\*[\s\S]*?\*\/" File.php
Where the “-M” does multiline searching, “-o” only returns the matching part of the line, and the “[\s\S]” matches any character including line breaks.
You can’t use
sudo directly with
echo in shell scripts / command line, so you need to use
tee with append (
-a). For example (simplified script example to update /etc/hosts for localhost entries):
if [ $(cat /etc/hosts | egrep -c "\s$1") == 0 ]; then echo "127.0.0.1 $1" | sudo tee -a /etc/hosts fi
yum -y install yum-plugin-security
# To display all updates that are security relevant, and get a reutrn code on whether there are security updates enter:
yum --security check-update
# To upgrade packages that have security errata (upgrades to the latest available package) use:
yum --security update
# To upgrade packages that have security errata (upgrades to the last security errata package) use:
yum --security update-minimal
# See yum-security man page for more information:
man 8 yum-security