Skip to content

Instantly share code, notes, and snippets.

@ipedrazas
ipedrazas / gist:06054fa052f629fc8ef2
Created September 10, 2014 23:49
Running Cassandra and CQLSH in 2 Docker containers
docker run -d -name cass1 poklet/cassandra
# Run cqlsh
docker run -it --rm --link cass1:cass1 poklet/cassandra bash -c 'cqlsh $CASS1_PORT_9160_TCP_ADDR'
@ipedrazas
ipedrazas / gist:2c93f6e74737d1f8a791
Created September 18, 2014 22:13
List Docker Container Names and IPs
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}
@ipedrazas
ipedrazas / gist:4207ec9da9e5cd66cff6
Last active March 28, 2019 08:19
Accessing a running container

The nsenter tool is part of the util-linux package since version 2.23. It provides access to the namespace of another process. nsenter requires root privileges to work properly.

cd /tmp
curl https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz | tar -zxf-
cd util-linux-2.24
./configure --without-ncurses
make nsenter
cp nsenter /usr/local/bin

Get the container id from

@ipedrazas
ipedrazas / gist:b20d1791b272ccc8a0a6
Created September 30, 2014 10:09
ubuntu pasting between vim and the rest of the world
sudo apt-get install vim-athena
"+yy > copy
"+p < paste
# finally
@ipedrazas
ipedrazas / gist:69064fced0b7db91ea0c
Created October 4, 2014 20:46
siege cassandra servlet
for i in {1..100000}
do
json='{"url": "http://test.com/test'$i'", "title": "test '$i'", "user": "fce70d20-3f7d-11e4-8a23-45898ba0e0df", "source": "bc-test", "tags": ["curl"]}'
curl -d $json -H 'Content-Type: application/json' http://localhost:8080/dotmarks ;
done
FROM ubuntu
MAINTAINER Ivan Pedrazas "ipedrazas@gmail.com"
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
@ipedrazas
ipedrazas / gist:c6b9e9fcd5a9d3192946
Created October 8, 2014 13:34
install latest docker Ubutnu
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
@ipedrazas
ipedrazas / knife cheat
Last active December 13, 2021 11:50
Hello!
# knife cheat
## Search Examples
knife search "name:ip*"
knife search "platform:ubuntu*"
knife search "platform:*" -a macaddress
knife search "platform:ubuntu*" -a uptime
knife search "platform:ubuntu*" -a virtualization.system
knife search "platform:ubuntu*" -a network.default_gateway
@ipedrazas
ipedrazas / gist:df1fccd446962ef6e348
Created October 29, 2014 09:19
Shutdown all running Vagrant boxes
vagrant global-status | ruby -ane '`cd #{$F[4]} && vagrant halt` if $F[3] == "running"'
@ipedrazas
ipedrazas / gist:bb8cbf9c169e7030f77d
Created November 25, 2014 14:11
redis upstart with docker
description "Redis container"
author "Me"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
/usr/bin/docker start -a redis_server
end script