Skip to content

Instantly share code, notes, and snippets.

View rsercano's full-sized avatar
🎯
Focusing

Sercan Özdemir rsercano

🎯
Focusing
View GitHub Profile
@rsercano
rsercano / SelfExpiringHashMap.java
Created July 27, 2019 09:06 — forked from pcan/SelfExpiringHashMap.java
SelfExpiringHashMap - a Java Map which entries expire automatically after a given time; it uses a DelayQueue internally.
/*
* Copyright (c) 2018 Pierantonio Cangianiello
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is

Keybase proof

I hereby claim:

  • I am rsercano on github.
  • I am sercandrop (https://keybase.io/sercandrop) on keybase.
  • I have a public key ASBt0ftWoFzNPEgrnYchicfwUzBXtLzAqQRblMp746dPMQo

To claim this, I am signing this object:

As described on the Docker Machine SSH reference, the docker-machine CLI invokes the standard OpenSSH client so we can use the common SSH tunneling syntax here. The following command will forward port 3000 from the default machine to localhost on your host computer's loopback interface. Using 0.0.0.0 as bind_address will make it bind to all interfaces:

$ docker-machine ssh default -L 0.0.0.0:3000:localhost:3000

So, the container running at machine's port 3000 can be reached through localhost:3000 or any of your interfaces' IP (i.e. 192.168.1.10:3000). That'd be useful to access your containerized services from other devices in your LAN.

@danguita

mkdir .ssh
chmod 700 .ssh
cd .ssh
touch authorized_keys
chmod 600 authorized_keys

in local

@rsercano
rsercano / docker_rmi_all
Last active June 16, 2017 11:33
Docker remove all containers and images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Delete all exited containers
sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
# Delete all unused images