Skip to content

Instantly share code, notes, and snippets.

View sudo-bmitch's full-sized avatar

Brandon Mitchell sudo-bmitch

View GitHub Profile
@sudo-bmitch
sudo-bmitch / README.md
Last active November 9, 2018 14:52
Docker SSH Remote Setup

Assumptions: remote host is running an older docker version, on Linux, and the user shell is bash.

This script is used to setup a remote docker host running an engine prior to 18.09 to allow remote docker ssh based access. It will upgrade the docker client used by the specific user to 18.09, placing the client binary in $HOME/bin/docker and updating .bashrc to prioritize $HOME/bin over the rest of the path. Once run on the remote host, you can connect to it from another docker 18.09 or newer client over ssh using:

@sudo-bmitch
sudo-bmitch / console-log.md
Created February 22, 2018 14:04
How inodes work in containers when you tail a file

Docker filesystem layers can be tricky to wrap your head around, and even more so how indoes work. Lets take an example and see what happens when you tail a file that exists in the image as part of your container entrypoint:

host$ docker run -d --rm --name test-inode debian tail -f /etc/issue                              
54bbfa8fa1f6751593dcf23103a1cdaec7fde8ffbcb3e31bab466b4f7a3581e7

Now make some changes to the file:

@sudo-bmitch
sudo-bmitch / console-log.md
Created February 2, 2018 14:08
Docker PS default formatting

Start with a normal docker ps output:

$ docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS   PORTS               NAMES
4edf61bfedce        prom/node-exporter:latest        "/bin/node_exporter …"   18 hours ago        Up 18 hours   9100/tcp            prometheus_node-exporter.q44zx0s2lvu1fdduk800e5ini.e68ujezn8rsvsll8epgay2oxi
8ad16badf470        grafana/grafana:latest           "/run.sh"                18 hours ago        Up 18 hours   3000/tcp            prometheus_grafana.1.5qhwvzvlng8ny8utzdajhxsyo
822f8207aee0        prom/prometheus:latest           "/bin/prometheus --c…"   18 hours ago        Up 18 hours   9090/tcp            prometheus_prometheus.1.umq9zg7qpu8cyluwbo4awzhtx
8c3f044d503b        prom/alertmanager:latest         "/bin/alertmanager -…"   18 hours ago        Up 18 hours   9093/tcp            prometheus_alertmanager.1.vtqoaudacac1xlgh0xvvb7j2x
7d32bb10f579        google/cadvisor:latest           "/usr/bin/cadvisor -…"   18
@sudo-bmitch
sudo-bmitch / console.log
Created January 30, 2018 15:24
Docker ARGS as environment variables
$ cat df.build-arg
FROM busybox
ARG ARGNAME=default
RUN env
RUN echo "ARGNAME=${ARGNAME}"
RUN echo "ARG Prefix=${ARGNAME%_*}" \
&& echo "ARG Suffix=${ARGNAME#*_}"
CMD env
@sudo-bmitch
sudo-bmitch / gist:a46b65bdf08f44b34d6a53122af3a75a
Created January 26, 2018 12:31
Lookup Keys for Formatted Output
# docker info is great for users to read, but takes work to parse in a script
$ docker info
Containers: 9
Running: 4
Paused: 0
Stopped: 5
...
Swarm: active
NodeID: xxx
Is Manager: true
@sudo-bmitch
sudo-bmitch / console log
Created September 17, 2016 14:51
docker-compose env_file
$ cat docker-compose.env.yml
version: '2'
services:
test:
image: busybox
command: env
env_file: ./env.data
environment:
- VAL="from compose"