Skip to content

Instantly share code, notes, and snippets.

View rkuzsma's full-sized avatar

Rich Kuzsma rkuzsma

View GitHub Profile
@rkuzsma
rkuzsma / WaitFor.java
Created December 30, 2016 03:54
Java utility class to wait for ports and URL responses to be available
/**
* General utilities to wait for ports and URL responses to be available.
* Especially useful when waiting for container services to be fully "up".
*/
public class WaitFor {
private static final Logger logger = LoggerFactory.getLogger(WaitFor.class.getClass());
public static void waitForPort(String hostname, int port, long timeoutMs) {
logger.info("Waiting for port " + port);
@rkuzsma
rkuzsma / DockerCompose.java
Created December 30, 2016 03:52
Utility for launching local containers via docker-compose.
public class DockerCompose {
private final File dockerSrc;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public DockerCompose(String dockerSrcDir) {
dockerSrc = new File(dockerSrcDir);
if (!dockerSrc.exists()) {
throw new RuntimeException("Docker source path does not exist: " + dockerSrcDir);
}
logger.info("Docker source path: " + dockerSrc.getAbsolutePath());
}
@rkuzsma
rkuzsma / docker-bash-completion.md
Last active November 18, 2023 09:11
How to configure Bash Completion on Mac for Docker and Docker-Compose

How to configure Bash Completion on Mac for Docker and Docker-Compose

Copied from the official Docker-for-mac documentation (thanks Brett for the updated doc pointer):

Install shell completion

Docker Desktop for Mac comes with scripts to enable completion for the docker, docker-machine, and docker-compose commands. The completion scripts may be found inside Docker.app, in the Contents/Resources/etc/ directory and can be installed both in Bash and Zsh.

Bash

Bash has built-in support for completion To activate completion for Docker commands, these files need to be copied or symlinked to your bash_completion.d/ directory. For example, if you installed bash via Homebrew:

@rkuzsma
rkuzsma / gist:b9a0e342c56479f5e58d654b1341f01e
Last active May 18, 2024 15:40
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@rkuzsma
rkuzsma / add_docker_to_etc_hosts.sh
Created April 9, 2016 22:07
Add (or replace) an entry called "dockermachine" in /etc/hosts that points to your local "docker-machine ip" so you can use http://dockermachine/
#!/bin/bash
# Add (or replace) an entry called "dockermachine" in /etc/hosts that points to
# your local "docker-machine ip" so you can use http://dockermachine/
eval $(docker-machine env)
readonly DOCKER_HOST_NAME="dockermachine"
readonly HOSTS_FILE="/etc/hosts"
readonly TMPFILE=$(mktemp)
readonly DOCKER_HOST_IP=$(docker-machine ip)
readonly DOCKER_HOST_ENTRY="$DOCKER_HOST_IP $DOCKER_HOST_NAME"
echo "Adding '$DOCKER_HOST_IP $DOCKER_HOST_NAME' entry to '$HOSTS_FILE' so you can use http://$DOCKER_HOST_NAME URLs for testing"