容器网络Debug工具箱

Net Tools

查询服务内部TCP状态

1
PATTERN=redis sh -c "nsenter -t `docker ps  | grep $PATTERN | awk '{print $1}' | xargs  docker inspect -f '{{.State.Pid}}'` -n netstat -ntuo"

Mac下容器内部访问宿主机网络

Use your internal IP address or connect to the special DNS name host.docker.internal which will resolve to the internal IP address used by the host.

자세히 보기

镜像站快速替换

alpine

1
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

Debian

1
2
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sudo sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list

Ubuntu

1
sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

CyclicBarrier 详解

A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released.

如Docs中所言,一个同步的工具能够让所有的线程等到一个集中点再继续执行。

Overview

1
2
3
4
5
6
public interface Future<V> {
boolean cancel(boolean mayInterruptIfRunning);
boolean isCancelled();
boolean isDone();
V get() throws InterruptedException, ExecutionException;
V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;

자세히 보기

如何工作

本来我是不愿意写一个这么大的标题的,但是最近被工作缠身无法自拔,恰好一个同事也无心工作,还是回归下自己对于工作方法论的认知。

原理

大部分的讲工作的指导性书籍的核心思想我在这里做一个抽象升华:

把注意力解放出来
想要赞成这个观点,第一步就是要承认,我们每一个的注意力是有限的,我们一天能够高效办公/学习的时候是一个浮动不大的值。
我们想要把自己的注意力释放到值得投入的事情上,这就是所有的工作指导手册的核心。

자세히 보기