Docker
How to Make a Port Accessible Only to a Specified IP
· β˜• 1 min read
1. Host Service Ports 1 2 iptables -I INPUT -p tcp --dport 80 -j DROP iptables -I INPUT -p tcp -s 1.2.3.4 --dport 80 -j ACCEPT This allows only 1.2.3.4 to access port 80 on the local host. 2. Docker Service Ports For services started like docker run -d -p 80:80 shaowenchen/demo:whoami, the method above does not work; the rule has to be added to the DOCKER-USER chain.

How to Hijack docker.io Image Traffic to a Private Repository
· β˜• 4 min read
1. Self-signing a *.docker.io Domain Certificate 1.1 Creating a CA Certificate Generate the CA certificate private key 1 openssl genrsa -out ca.key 4096 Generate the CA certificate 1 2 3 4 openssl req -x509 -new -nodes -sha512 -days 3650 \ -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=chenshaowen.com" \ -key ca.key \ -out ca.crt 1.2 Creating a *.

Problems Using the obsutil Command in Containers
· β˜• 1 min read
1. The container’s ulimit is set too low Error message: 1 2 3 4 5 6 7 CheckpointDir: /root/.obsutil_checkpoint OutputDir: /root/.obsutil_output runtime: mlock of signal stack failed: 12 runtime: increase the mlock limit (ulimit -l) or runtime: update your kernel to 5.3.15+, 5.4.2+, or 5.5+ fatal error: mlock failed Under Docker, you can add the ulimit parameter at startup 1 docker run -it --ulimit memlock=-1 .

Migrating Docker Storage to a New Disk
· β˜• 2 min read
1. Formatting the Disk Check the new disk 1 fdisk -l Usually, the second disk is named /dev/sdb. Partition the disk 1 fdisk /dev/sdb You will be prompted to enter parameters: command (m for help):n Partition number(1-4):1 First cylinder (1-22800,default 1):Enter command (m for help):w Format the disk as ext4 1 mkfs.

Pulling DockerHub images fails to connect to Cloudflare
· β˜• 2 min read
1. Error message When pulling an image, you will occasionally run into the following error: 1 2 3 4 5 6 7 8 docker pull node:10.16-alpine 10.16-alpine: Pulling from library/node e7c96db7181b: Already exists 50958466d97a: Pulling fs layer 56174ae7ed1d: Pulling fs layer 284842a36c0d: Pulling fs layer error pulling image configuration: Get https://production.