Skip to content

Instantly share code, notes, and snippets.

@leafnode
leafnode / script.sh
Created October 27, 2020 13:59
Run MySQL from docker with port mapping
docker run \
--detach \
--name=[container_name]\
--env="MYSQL_ROOT_PASSWORD=[my_password]" \
--publish 6603:3306 \
--volume=/root/docker/[container_name]/conf.d:/etc/mysql/conf.d \
mysql
#!/bin/sh
jq --slurp --raw-input '{"text": "\(.)", "mode": "markdown"}' < README.md | \
curl --data @- https://api.github.com/markdown | \
tee README.html
@leafnode
leafnode / Dockerfile
Last active January 16, 2020 08:55
Google Cloud SDK in docker container support
# one-liner: RUN curl -sSL https://sdk.cloud.google.com | bash
# Downloading gcloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
# Installing the package
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh
@leafnode
leafnode / script.sh
Created December 20, 2019 15:01
Get pods with node name with filtering #docker #kubernetes
#!/bin/sh
kubectl get pods -l 'app==coredump-agent' --template='{{range .items}}{{.spec.nodeName}} {{.metadata.name}}{{"\n"}}{{end}}'
kubectl get pods --template '{{range .items}}{{if eq .spec.nodeName "ip-254-0-90-30.ec2.internal"}}{{.metadata.name}}{{"\n"}}{{end}}}{{end}}'
@leafnode
leafnode / syslog_netcat.sh
Created July 15, 2019 10:46 — forked from dwallraff/syslog_netcat.sh
Use netcat to send syslog messages
# Here’s how to create UDP syslog messages via nc, netcat:
echo ‘<14>_sourcehost_ messagetext’ | nc -v -u -w 0 _syslog-host_ 514
@leafnode
leafnode / script.sh
Created July 11, 2019 13:35
Dump network traffic from a docker container #docker
#!/bin/sh
# replace $container
docker run -t --net container:$container bretfisher/netshoot ngrep -d eth0 -x -q
@leafnode
leafnode / script.sh
Created July 11, 2019 13:34
debug container using strace #docker
#!/bin/sh
# replace $container
docker run --pid container:$container --cap-add SYS_PTRACE lukaszlach/strace -s 1024 -f -p 1
@leafnode
leafnode / script.sh
Created July 11, 2019 13:33
Run moncho/dry docker management tool #docker
#!/bin/sh
docker run -it -v /var/run/docker.sock:/var/run/docker.sock moncho/dry
@leafnode
leafnode / script.sh
Created July 11, 2019 13:31
Run local portainer #docker
#!/bin/sh
docker volume create portainer_data
docker run -d \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer
@leafnode
leafnode / script.sh
Created July 11, 2019 10:52
Analyse docker image filesystem #docker #dive
#!/bin/sh
# change tag!
docker run --rm -it \
-v /usr/local/bin/docker:/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":"$(pwd)" \
-w "$(pwd)" \
-v "$HOME/.dive.yaml":"$HOME/.dive.yaml" \