Wednesday, August 19, 2015

Docker - Remove All

Sometimes you just need to remove everything from Docker and have a clean slate.

# Delete all containers 
docker rm $(docker ps -a -q)

# Delete all images 
docker rmi $(docker images -q)

Friday, December 19, 2014

Crude Ruby Script to ask for a Password to use for Private git Repo

The Intro

Good ole Docker. It is a powerful tool to setup your environments whether in production, dev or test. Plowing through and building a new container I discovered I had the need or want to pass an argument to the Dockerfile and let it log me into a private repo.

The Environment Variable. 

Looking through the Dockerfile documentation on
the docker.io website I saw this wonderful looking thing called an environment variable. When I first looked at it I thought that meant that we could pass them in from the host cli running the docker command. I was dead wrong. The environment variable does create a variable but its only for the container's environment. So what does that mean for us. Well if you think about the reason for Docker is for an unattended setup of an environment. Now if I were going to do this completely automated then I would probably create a ssh key and copy it over using Dockerfile. This is not what I wanted. I really wanted a seperation where I didn't store my password or ssh key within the environment. Below is my crude way of getting around this. 

The Gemfile 

source 'https://rubygems.org'
gem 'highline'
The Gemfile in this instance is very simple. You really could skip using highline all together, however I thought it would be cool to mask the password as you type.

The Ruby

require 'highline/import'
pass = ask("Enter your Password : "){ |q| q.echo = "*" }
file = File.open("dock_temp", "r")
text = file.read()
file.close
out = File.open("Dockerfile", "w")
out.puts text.gsub("$PASS", pass)
out.close
`docker build -t image_name .`
`rm Dockerfile`

The Ruby script will ask you for a password. Once input it will open the "dock_temp" file within the directory. Then we do a simple replacement of the $PASS variable to be the actual password that was input by the user. Once that is complete we write it to a file called Dockerfile.
The Docker file is the file used when you run "docker build". The Ruby script then makes a system call and it will build your environment. Lastly we want to get rid of the password just laying around so we delete the Dockerfile

The Temp Dockerfile

FROM ubuntu:14.10
RUN apt-get update
RUN apt-get install -y git

RUN git clone https://username:$PASS@bitbucket.org/username/your_repo.git
WORKDIR /your_repo
The Dockerfile template is very simple. It grabs a copy of ubuntu, updates the repo, installs git. At this point all you have to do is run the git clone and you have you code
Voila!!!

Tuesday, November 11, 2014

Monday, August 18, 2014

Sending and email using Telnet

Open up Telnet
telnet smtp.yourdomain.com 25

If you need SSL do this instead
openssl s_client -connect smtp.yourdomain.com:465

Tell the server where you are coming from.
ehlo localhost

Login to the server. You will need your username and password converted to Base 64.



auth login
334 VXNlcm5hbWU6
username
334 UGFzc3dvcmQ6
password

Now compose your email.
mail from: <your_email@yourdomain.com>
rcpt to: <destination@domain.com>
data
Type in your email 
.

Wednesday, July 23, 2014

God is bigger than the Boogie Man - Guitar Chords

This song is called "God is Bigger than the Boogie Man" which came from Veggietales and is quite the hit for the preschoolers at church. There are some more words that are said when played in the movie however for the kids at church this chorus works wonders.

G                      D
God is bigger than the boogie man
A
He is bigger than Godzilla
D
Or the monsters on TV
G                         D
Oh God is bigger than the boogie man
A                      G       D
He is watching out for you and me.