Skip to content

Instantly share code, notes, and snippets.

View BretFisher's full-sized avatar
🗃️
All Day Containers!

Bret Fisher BretFisher

🗃️
All Day Containers!
View GitHub Profile
@BretFisher
BretFisher / Dockerfile
Last active April 26, 2024 00:00
WIP sample Laravel php_fpm plus nginx plus supervisor Docker setup with npm, composer, bower, and more
FROM yourdockername/base-php-nginx:latest AS build
# BUILD STAGE
# the primary reason we have two build stages is so SSH key of private repo's will never
# be in final image
# COPY IN BUILD SSH KEY
# It won't be copied to final image
# add this build arg to compose file
ARG BUILDKEY
RUN if [ -z "$BUILDKEY" ]; then echo "BUILDKEY SSH NOT SET - ERROR"; exit 1; else : ; fi
@BretFisher
BretFisher / docker-for-mac.md
Last active April 25, 2024 15:59
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@BretFisher
BretFisher / cert.sh
Created August 13, 2020 18:45
docker compose with traefik and certs
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DOMAIN_NAME=$1
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
@BretFisher
BretFisher / update.sh
Created February 8, 2016 18:42
Mac Update/Cleanup Script
#!/bin/sh
# store the current dir
CUR_DIR=$(pwd)
# Update App Store apps
sudo softwareupdate -i -a
# Update Homebrew (Cask) & packages
brew update
@BretFisher
BretFisher / repair-windows-update.bat
Last active April 8, 2024 15:08
Reset Windows Update components RE: KB971058
@echo off
REM Automation of Steps to Reset Windows Updates
REM Tested on Server 2012 R2, likely works on everything Win7/2008R2 and up
REM by Bret Fisher bret@bretfisher.com
REM also find this info and more in a blog article at http://www.fishbrains.com/2015/01/29/untitled/
REM Origional Steps (identical to this): http://support.microsoft.com/kb/971058
REM This file Copyright MIT License
REM Stop Services
@BretFisher
BretFisher / docker-swarm-ports.md
Last active April 4, 2024 22:19
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

@BretFisher
BretFisher / swarm-upgrade.md
Last active March 19, 2024 09:37
docker swarm upgrade

Replace your Swarm Manager and Workers with updated versions of docker

  • it's best to replace nodes, don't do apt/yum upgrades.
  • both would work, but VM replacment forces me to think of it as immutable and prevents making pets
  • if you don't want to update join scripts for manager IP's, then do something like Elastic IP's so manager IP's won't change.

Lets assume you have 3 managers and 3 workers on 17.06 and you want to update to 17.12

  • managers: m1, m2, m3
@BretFisher
BretFisher / pcat-install.sh
Last active February 6, 2024 14:41
On macOS: Install pygmentize and alias pcat for shell code syntax highlighting
# first install pygmentize to the mac OS X or macOS system with the built-in python
sudo easy_install Pygments
# then add alias to your ~/.bash_profile or ~/.bashrc or ~/.zshrc etc.
alias pcat='pygmentize -f terminal256 -O style=native -g'
@BretFisher
BretFisher / docker-for-windows.md
Last active February 1, 2024 21:57
Getting a Shell in the Docker for Windows Moby VM

2018 Update: Easiest option is Justin's repo and image

Just run this from your CLI and it'll drop you in a container with full permissions on the Moby VM. Only works for Moby Linux VM (doesn't work for Windows Containers). Note this also works on Docker for Mac.

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1

@BretFisher
BretFisher / Dockerfile
Last active January 4, 2024 10:11
Multi-stage Dockerfile example of installing dependencies with COPY --from
# any images you use later, add them here first to create aliases
# I like keeping all my versions at the top
FROM node:14.3-slim as node
FROM php:7.2.1-fpm-slim as php
FROM nginx:1.17 as nginx
# The real base image to start from
FROM ubuntu:focal-20210827 as base
# install apt stuff