var b58Alphabet = []byte("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
func Base58Encode(input []byte) []byte { var result []byte
x := big.NewInt(0).SetBytes(input)
base := big.NewInt(int64(len(b58Alphabet))) zero := big.NewInt(0) mod := &big.Int{}
for x.Cmp(zero) != 0 { x.DivMod(x, base, mod) result = append(result, b58Alphabet[mod.Int64()]) }
ReverseBytes(result)
for _, b := range input { if b == 0x00 { result = append([]byte{b58Alphabet[0]}, result...) } else { break } } return result
}
func Base58Decode(input []byte) []byte { result := big.NewInt(0) zeroBytes := 0 for _, b := range input { if b != b58Alphabet[0] { break } zeroBytes++ } payload := input[zeroBytes:] for _, b := range payload { charIndex := bytes.IndexByte(b58Alphabet, b) result.Mul(result, big.NewInt(int64(len(b58Alphabet)))) result.Add(result, big.NewInt(int64(charIndex))) }
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3548302772b1 redis:3.2-alpine "docker-entrypoint.s…" 3 weeks ago Up 3 weeks 0.0.0.0:6379->6379/tcp redis_redis_1 37259a661f27 xxiu/mysql "docker-entrypoint.s…" 3 weeks ago Up 3 weeks 0.0.0.0:3306->3306/tcp, 33060/tcp mysql_mysql_1
仓库(Repository)
仓库可看成一个代码控制中心,用来保存镜像。
自己搭: Harbor
阿里云:
核心技术
Namespaces
Cgroup
Union file systems
Container format
Namespaces & Cgroup
linux 内核做资源隔离的两个概念。
所以 docker 和虚拟机的区别在于:
虚拟机虚拟了整套的操作系统,
docker 只是在linux 内核上做了资源隔离。
Namespaces
资源隔离
cgroup
Cgroup:控制程序对资源的占用。
对进程组使用的资源总额进行限制;
通过分配CPU时间片数量/磁盘IO/带宽大小,实际上就是相当于控制子进程运行的优先级。
统计系统资源使用量,比如CPU使用时间,内存使用量等
进程控制,恢复执行进程
Union file systems
boots: boot loader + kernel ,用户不可修改 (共享主机的内核)
root file system : 包括典型的 linux 目录结构: /dev/proc /bin/etc/lib/usr/tmp 等配置文件,二进制文件,库文件
You must reboot for the installation of osxfuse to take effect.
==> Satisfying dependencies ==> Downloading https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.10.4/osxfuse-3.10.4.dmg ==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/1867347/58615480-1769-11ea-8f1f-f6cc029e4f08?X-Amz-Algorithm=AWS4-HMAC-SH ######################################################################## 100.0% ==> Verifying SHA-256 checksum for Cask 'osxfuse'. ==> Installing Cask osxfuse ==> Running installer for osxfuse; your password may be necessary. ==> Package installers may write to any location; options such as --appdir are ignored. Password: installer: Package name is FUSE for macOS installer: Installing at base path / installer: The install was successful. ==> Changing ownership of paths required by osxfuse; your password may be necessary 🍺 osxfuse was successfully installed!