1.拉取nettools镜像
[root@localhost app]# docker search nettools
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/travelping/nettools A simple, small, alpine-based docker image... 5 [OK]
docker.io docker.io/dyrnq/nettools A small debian-based docker image with ha... 2
docker.io docker.io/jrecord/nettools Some common network tools in a centos cont... 2
...
[root@localhost app]# docker pull docker.io/travelping/nettools
[root@localhost app]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/travelping/nettools latest 2d2c7dadefe0 3 years ago 23.8 MB
2.将镜像打标签
docker tag 2d2c7dadefe0 10.10.10.10/images/app:20231031
3.上传到镜像仓库(镜像仓库自己去阿里云创建)
[root@localhost app]# docker push 10.10.10.10/images/app:20231031
The push refers to a repository [10.189.4.241/gd-yares/app]
c268ed4fd0f2: Pushed
2f0aae61ad3d: Pushed
c18e1afa015f: Pushed
35c20f26d188: Layer already exists
c3fe59dd9556: Layer already exists
6ed1a81ba5b6: Layer already exists
a3483ce177ce: Layer already exists
ce6c8756685b: Layer already exists
30339f20ced0: Layer already exists
0eb22bfb707d: Layer already exists
a2ae92ffcd29: Layer already exists
20231031: digest: sha256:b42f707163729d38f84dc435e3fd2e315907dc63066255c549435f4e639f1a94 size: 2631
4.k8s环境拉取镜像
vim deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nettool
labels:
app: nettool
spec:
replicas: 1
selector:
matchLabels:
app: nettool
template:
metadata:
labels:
app: nettool
spec:
containers:
- name: nettool
image: 10.10.10.10/images/app:20231031
imagePullPolicy: Always
command: ["/bin/sh", "-ce", "tail -f /dev/null"]