Docker交流群组
Telegram Docker群组
YouTube视频
Docker Storage: Designing a Platform for Persistent Data
Question: How do you deal with big companies that they can do it all?Speaker: #Solomon_Hykes
Understand Kubernetes
Kubernetes Deconstructed: Understanding Kubernetes by Breaking It Down
容器时间同步
1
|
-v /etc/localtime:/etc/localtime:ro |
Container Messaging
First-In, First-Out (FIFO)
Message queue
Message processing by containers
Container1 failed, message put on top of message queue
After message B completed, message A processing by container2
Messaging System
privileged mode
--privileged
Give extended privileges to this container
1
2
3
4
|
$ docker run -it --rm ubuntu:14.04 ip link add dummy0 type dummy
RTNETLINK answers: Operation not permitted
$ docker run -it --rm --privileged ubuntu:14.04 ip link add dummy0 type dummy
success! |
–cap-add & –cap-drop
--cap-drop
Drop Linux capabilities
--cap-add
Add Linux capabilities
- capabilities list
1
2
3
4
|
$ docker run -it --rm ubuntu:14.04 ip link add dummy0 type dummy
RTNETLINK answers: Operation not permitted
$ docker run --rm -ti --cap-drop ALL --cap-add NET_ADMIN ubuntu:14.04 ip link add dummy0 type dummy
success! |
–init (孤儿进程回收)
PID 1
的问题
- 容器内没有host的init进程来回收孤儿进程。
- 当一个父进程开启一个子进程,但是在某个时间,当父进程退出或者被杀掉后,在该容器内由于没有父进程以及其他回收孤儿进程的进程,该子进程会成为一个僵尸进程。
- 由于容器内进程都在同一个命名空间,如果容器退出了,该僵尸进程也会被清除。
1
2
3
|
$ docker run -ti ubuntu bash -c 'sleep 50'
^C^C^C^C^C^C^C^C^C
<Ctrl-C not working> |
孤儿进程回收
- 如果想在容器内运行多个进程,容器的起始进程必须回收孤儿进程(orphan reaping)
1
2
|
$ docker run -ti --init ubuntu bash -c 'sleep 50'
^C <Ctrl-C worked just fine> |
其他选择
推荐阅读
Attach docker-for-mac tty
Attach to docker for mac tty:
1
|
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty |
Quick Install
Docker
1
|
curl -fsSL get.docker.com | CHANNEL=stable sh |
Start Docker
1
2
|
systemctl enable docker
systemctl start docker |
Docker Compose
1
2
3
|
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose |
Docker App
1
2
3
4
5
6
7
8
9
|
# linux
wget https://github.com/docker/app/releases/download/v0.2.0/docker-app-linux.tar.gz
tar xf docker-app-linux.tar.gz
cp docker-app-linux /usr/local/bin/docker-app
# macOS
wget https://github.com/docker/app/releases/download/v0.2.0/docker-app-darwin.tar.gz
tar xf docker-app-darwin.tar.gz
cp docker-app-darwin /usr/local/bin/docker-app |
modify docker lib dir
1
2
3
4
5
6
7
|
docker ps -q | xargs docker kill
stop docker
cd /var/lib/docker/devicemapper/mnt
umount ./*
mv /var/lib/docker $dest
ln -s $dest /var/lib/docker
start docker |
remove image
1
|
docker image ls | grep '<none>' | awk '{print $3}' | xargs docker rmi |
Bugfix
docker daemon卡住的一些解决方法
1
2
|
# 查看docker daemon日志
journalctl -f -u docker |
1
|
systemctl reset-failed docker |
1
|
systemctl restart docker |
1
2
|
rm -rf /var/run/docker.pid
systemctl restart docker |
References: