Archive for the ‘ bash ’ Category

Advice on building Docker images on Windows

Since the stable release of “Docker for Windows” in July 2016, you can work quite well with Docker on Windows. And its mostly the same workflows and user-experience as on Linux/MacOS.

However there are some things that could be improved (like sharing folders/drives between Host and Containers) and also some more not-so-obvious quirks.
One of those problems can arise when building images and the resulting container would exit immediately with

standard_init_linux.go:175: exec user process caused "no such file or directory

Read on after the jump whats causing this and how to fix it and prevent it from happening again.

Read more

Playing with YUM API

I was migrating from one server to another and because I love python, I really try to involve it into each and every script I’m writing.
So I saved all of my installed packages in a text file called installed.txt , and using the yum python API, I managed to install all the needed packages as easy as this:

Read more

Howto resume SCP transfer

From time to time you will end up with an incomplete scp transfer. That gets annoying when the total transfer was high. The solution is to use rsync for resuming like so:

rsync -partial -progress --rsh=ssh user@host:/path/to/remote/file /path/local/file

# short version
rsync -P --rsh=ssh user@host:/path/to/remote/file /path/local/file

You can also add an alias so you dont have to remember all those flags. Add to your .bashrc or .bash_aliases

alias scpresume="rsync -P --rsh=ssh"

iptables settings for outgoing FTP

Getting FTP to fully work with iptables can be a pain in the ass. Thinking of active and passive mode here. Even if you are familiar with iptables, its easier to copy/paste this rather than writing this down out of your head. (I am here refering to outgoing FTP connections, meaning you are acting as the client). So here are the rules you were looking for:

-A INPUT -p tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -j ACCEPT

-A OUTPUT -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --dport 20 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT

Basically what this does is tell iptables to open up FTP command port 21 and data port 20 for connection related to ones established on 21. It also allows the random ports >=1024 for related connections.
These rules apply for both active and passive connections.