官网
https://docs.docker.com/
https://hub.docker.com/
https://docs.docker.com/engine/install/debian/
#Docker安装
https://github.com/docker/docker-install
curl -sSL https://get.docker.com | bash
wget -qO- get.docker.com | bash
curl -sSL https://get.docker.com/ | sh
systemctl start docker
systemctl status docker
systemctl enable docker
安装 docker Compose 1.x版本
https://docs.docker.com/compose/cli-command/#install-on-linux
curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
创建连接放入/usr/bin,因为/usr/bin在PATH目录下可以不用绝对路径直接访问。
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
卸载
rm /usr/local/bin/docker-compose
安装 docker compose v2版本
mkdir -p ~/.docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
要为系统上的所有用户安装 Docker Compose,请替换~/.docker/cli-plugins为/usr/local/lib/docker/cli-plugins.
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version
#常用命令
docker info
systemctl start docker
systemctl stop docker
systemctl restart docker
systemctl status docker
systemctl enable docker
docker ps -aq
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker system prune -a
docker exec -it 049d98ba2265 bash
#文件复制
docker cp 049d98ba2265:/var/www/html/index.php /root
docker cp /root/index.php 049d98ba2265:/var/www/html
docker commit:将容器保存为镜像 docker commit 容器名称 新的镜像名称
docker save -o:将镜像备份为tar文件 docker save -o tar文件名 镜像名
docker load -i:根据tar文件恢复为镜像 docker load -i tar文件名
docker支持IPV6
nano /etc/docker/daemon.json
{
"ipv6": true,
"fixed-cidr-v6": "fd00:db8:abc1::/64",
"experimental": true,
"ip6tables": true
}
配置完成后,重启docker,然后启动一个busybox的测试容器来ping -6测试ipv6的网络是否通了
docker run -it --name=test busybox
#ping -6 www.google.com
docker network ls
docker network inspect bridge
docker exec c4ba39c6a264 ping6 google.com
#Alist - https://github.com/Xhofe/alist - https://alist-doc.nn.ci/
docker pull xhofe/alist
docker run -d --restart=always -v /etc/alist:/opt/alist/data -p 5244:5244 --name="alist" xhofe/alist:latest
#Initial password:
docker logs alist
# or
docker exec -it alist ./alist -password
#配置反向代理
注释:
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log off;
}
添加:
location / {
proxy_pass http://127.0.0.1:5244/;
rewrite ^/(.*)$ /$1 break;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade-Insecure-Requests 1;
proxy_set_header X-Forwarded-Proto https;
}