1. Install Podman

# apt update

# apt install podman -y

# podman --version
podman version 4.9.3

# podman info

2. Podman Service

# systemctl enable podman.socket

# systemctl start podman.socket

# systemctl stop podman.socket

# systemctl restart podman.socket

# systemctl status podman.socket

3. Docker代理

  • vim /etc/docker/daemon.json

  • systemctl daemon-reload && systemctl restart docker

  • docker pull quay.io/keycloak/keycloak:22.0

  • docker pull daocloud.io/keycloak/keycloak:22.0

  • docker pull mirror.baidubce.com/keycloak/keycloak:22.0

{
  "registry-mirrors": [
  	"https://docker.1panel.live",
  	"https://docker.1panelproxy.com",
  	"https://proxy.1panel.live",
  	"https://mirror-gcr.onrender.com",
  	"https://docker.anyhub.us.kg",
  	"https://dockerhub.jobcher.com",
  	"https://dockerhub.icu",
    "https://mirror.baidubce.com",
    "https://dockerproxy.com",
    "http://hub-mirror.c.163.com",
	"https://hub-mirror.c.163.com/",
    "https://ccr.ccs.tencentyun.com",
    "https://ustc-edu-cn.mirror.aliyuncs.com",
    "https://9cpn8tt6.mirror.aliyuncs.com",
    "https://no1pfk8z.mirror.aliyuncs.com",
	"https://kfwkfulq.mirror.aliyuncs.com",
	"https://2lqq34jg.mirror.aliyuncs.com",
	"https://pee6w651.mirror.aliyuncs.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://dockerhub.mirrors.nwafu.edu.cn/",
    "http://f1361db2.m.daocloud.io",
    "https://reg-mirror.qiniu.com",
    "https://registry.docker-cn.com",
    "https://ghcr.io"
  ]
}

systemctl daemon-reload && systemctl restart docker

4. 镜像操作

# 拉取镜像:docker pull OPTION NAME[:TAG]
docker pull mysql:8.2.0

# 标签镜像:docker tag SRC[:TAG] DEST_IMAGE[:TAG]
docker tag mysql:8.2.0 mysql:820

# 保存镜像:docker save OPTION IMAGE...
docker save -o ./mysql820.tar mysql:820

# 加载镜像
docker load < ./tarball.tar

5. 常见操作

# 删除镜像
docker rmi -f $(docker images)

# 删除退出状态容器
docker rm $(sudo docker ps -qf status=exited)

# 删除虚悬(dangling)镜像,仓库名和标签都为<none>的镜像
docker rmi $(docker images -f "dangling=true" -q)

# 停止并删除容器
docker stop $(docker ps -q) && docker rm $(docker ps -aq)

# 更新启动策略
docker update --restart=on-failure containerIdName

-e TZ=Asia/Shanghai
--restart=on-failure[:max-retries],always

# 容器IP
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql

6. Run

docker run \
	--name gitlab \
	-p 8080:80 \
	--privileged=true \
	--net network-common \
	-itd imageInfo

7. Harbor

  • 登录harbor:https://192.168.0.123

  • 创建项目/命名空间specification,专门用于存规范镜像,如jdk等

7.1. 推送镜像

# 拉取镜像
docker pull mysql:8.2.0

# 登录到Harbor:docker login <harbor_address>
docker login https://192.168.0.123

# 镜像打标签:docker tag local_image <harbor_address>/namespace/target_image
docker tag mysql:8.2.0 192.168.0.123/specification/mysql:8.2.0

# 构建镜像:docker build -t <harbor_address>/namespace/target_image target_path
docker build -t 192.168.0.123/specification/mysql:8.2.0 .

# 推送镜像:docker push <harbor_address>/namespace/target_image
docker push 192.168.0.123/specification/mysql:8.2.0

7.2. 拉取镜像

# 登录到Harbor:docker login <harbor_address>
docker login http://192.168.0.123

# 拉取镜像:docker pull <harbor_address>/namespace/target_image
docker pull 192.168.0.123/specification/mysql:8.2.0

7.3. Tag Save

docker tag gitlab/gitlab-ce:16.6.2-ce.0 gitlab:16.6.2.0 && \
	docker tag docker.elastic.co/kibana/kibana:8.11.2 kibana:8.11.2 && \
	docker tag docker.elastic.co/elasticsearch/elasticsearch:8.11.2 es:8.11.2 && \
	docker save -o ./gitlab16620.tar gitlab:16.6.2.0 && \
	docker save -o ./kibana8112.tar kibana:8.11.2 && \
	docker save -o ./es8112.tar es:8.11.2

docker load < ./gitlab16620.tar && \
	docker load < ./es8112.tar && \
	docker load < ./kibana8112.tar && \

8. 文件(夹)复制

# 本地镜像复制到远程
scp -r /elf/local/tarball.tar root@192.168.1.120:/elf/remote/

# 远程镜像复制到本地
scp -r root@192.168.1.120:/elf/remote/tarball.tar /elf/local/

# 本地文件夹复制到远程
scp -r /elf/local/ root@192.168.1.120:/elf/remote/

# 远程文件夹复制到本地
scp -r root@192.168.1.120:/elf/remote/ /elf/local/

9. 容器主机复制

# 主机复制到容器 docker cp <source> <container>:<destination>

# 容器复制到主机 docker cp <container>:<source> <destination>
docker cp es8:/usr/share/elasticsearch/config/certs/http_ca.crt /elf/http_ca.crt

10. Network

docker network create network-common

# docker network create -d bridge network-common

# docker inspect network-common

# docker network rm network-common