云计算day33

2024-08-28 03:36
文章标签 计算 day33

本文主要是介绍云计算day33,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在Docker file中定义所需要执⾏的指令,使⽤ docker build创建镜
像,过程中会按照dockerfile所定义的内容进⾏打开临时性容器,把
docker file中命令全部执⾏完成,就得到了⼀个容器应⽤镜像,每
⼀⾏命令都会出现容器,都会使⽤docker commit进⾏提交⼀个临
时性的镜像
注意执⾏的命令越多,镜像体积越⼤,所以需要优化镜像
Docker file关键字
1.FORM 指定基础镜像为该镜像的最后修改版本
2.FROM <image :tag>指定基础镜像为该镜像的⼀个tag版本
3.MAINTAINER
指定镜像创建者,企业内部不⽤指定,对外发
布也可以不指定
3.RUN 运⾏命令,安装软件
4.CMD 设置container启动时进⾏的操作,如果容器镜像中有这
个命名,启动容器时,不要⼿动让容器执⾏其他命令
5.ENTRYPORINT(⼊⼝点)cmd每次只能执⾏⼀个指令,
entrypoint可以多⾏执⾏。6.USER设置容器进程的⼀些⽤户
7.EXPOSE 暴露端⼝ 指定容器需要映射到宿主机的端⼝
8.ENV
设置环境变量 -e
9.ADD 从宿主机src复制⽂件到容器的dest路径
10.volumn 指定挂载点
11.WROKDIR 切换⽬录
12.ONBUILD在⼦镜像中执⾏指令
通过dockerfile创建⼀个在启动容器时,就可以启动httpd服务的镜
步骤
1. 创建⼀个⽬录,⽤于存储Docker file所使⽤的⽂件
1. 在此⽬录中创建Docker file⽂件,以及镜像制作所使⽤的⽂
1. 使⽤docker build创建镜像
1. 使⽤创建的镜像启动容器(验证)
思考
1. 基础镜像
1. yum -y install httpd
1. 使⽤脚本启动服务(httpd -k start)
1. 应该将httpd服务放在前端执⾏
1. 暴露端⼝ 80/tcp
1. 添加⼀个测试⽂件,⽤于验证软件是否可⽤
过程
# 1.创建⽬录
[root@docker001 ~]# mkdir test
# 2.跳转到⽬录中[root@docker001 ~]# cd test/
# 3.编辑启动脚本
[root@docker001 test]# vim start.sh
[root@docker001 test]# cat start.sh
######################################
#!/bin/bah
rm -rf /run/httpd/*
exec /sbin/httpd -D FOREGROUND
######################################
# 4.编辑index.html⽂件
[root@docker001 test]# vim index.html
# 5.编辑Dockerfile
[root@docker001 test]# vim Dockerfile
####################################
FROM centos_yum:v0
MAINTAINER "httpd server start
15773141955@163.com"
RUN yum clean all
RUN yum makecacheRUN yum -y install httpd
ADD start.sh /start.sh
RUN chmod -v +x /start.sh
Add index.html /var/www/html/
EXPOSE 80
WORKDIR /
CMD ["/bin/bash","/start.sh"]
####################################
# 6.创建镜像
[root@docker001 test]# docker build -t
centos:httpd .
[+] Building 51.6s (12/12) FINISHED
docker:default=> [internal] load build definition from
Dockerfile
0.0s
=> => transferring dockerfile: 309B
0.0s
=> [internal] load metadata for
docker.io/library/centos_yum:v0
0.0s
=> [internal] load .dockerignore
0.0s
=> => transferring context: 2B
0.0s
=> [1/8] FROM docker.io/library/centos_yum:v0
0.0s
=> [internal] load build context
0.0s
=> => transferring context: 180B
0.0s
=> [2/8] RUN YUM clean all
2.3s
=> [3/8] RUN YUM makecache
42.7s
=> [4/8] RUN YUM -y install httpd
5.8s
=> [5/8] ADD START.SH /START.SH
0.0s=> [6/8] RUN CHMOD -v +x /start.sh
0.2s
=> [7/8] ADD INDEX.HTML /VAR/WWW/HTML/
0.0s
=> exporting to image
0.5s
=> => exporting layers
0.4s
=> => writing image
sha256:a488bc9f4cfb58a91baa57c2ab9faf615d457ff8714
e4e958e7220a253469ed 0.0s
=> => naming to docker.io/library/centos:httpd
# 7.查看镜像
[root@docker001 test]# docker image ls
REPOSITORY TAG IMAGE ID CREATED
SIZE
centos httpd a488bc9f4cfb About a
minute ago 352MB
centos nginx 12fea1b890de 41 hours ago
366MB
centos java17 b6bf774de7bb 41 hours ago
550MB
centos_yum v0 191d9c84f461 2 days ago
260MBmysql latest a82a8f162e18 4 weeks ago
586MB
# 9.创建容器测试
[root@docker001 test]# docker run -d --name c0
centos:httpd
c245d9f9f3e0d6526d80e117ebd7b4c2870a1e12558192f1da
1e681cabdc4e87
[root@docker001 test]# docker ps --all
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
c245d9f9f3e0 centos:httpd "/bin/bash
/start.sh" 21 seconds ago Up 20 seconds
80/tcp c0
# 10.查看ip地址
[root@docker001 test]# docker inspect c0
# 访问测试
[root@docker001 test]# curl 172.17.0.2
p
pp
ppp
pppp
ppppppppppp
ppppppp
pppppppp
测试挂载其他项⽬
[root@docker001 test]# docker run -d -v
/opt:/var/www/html --name c1 centos:httpd
3c97af2d11a56b9c2f2ea4eb6bb0a7ff18d6f26d0f777f68a4
eb4a20b9c61835
[root@docker001 test]# eche
"adsfadfafwqrdfqdsafdgdfsgda" > /opt/index.html
-bash: eche: 未找到命令
[root@docker001 test]# echo
"adsfadfafwqrdfqdsafdgdfsgda" > /opt/index.html
[root@docker001 test]# curl 172.17.0.3
adsfadfafwqrdfqdsafdgdfsgda
yum -y install yum-plugin-ovl练习 配置nginx应⽤镜像
FROM centos:latest
MAINTAINER "NGINX"
RUN rm -rf /etc/yum.repos.d/*
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo
https://mirrors.aliyun.com/repo/Centos-vault-
8.5.2111.repo
RUN yum clean all && yum makecache
RUN yum -y install epel-release && yum -y
install nginx
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
WORKDIR /
CMD /usr/sbin/nginx[root@docker001 ~]# docker run -d --name c1 -
p80:80 -v /opt/:/usr/share/nginx/html/
centos:nginx
948f20e1ed4758e78759de8f9ce9b34a7f44c431bc8ead75b6
70e1a5b488654c
[root@docker001 ~]# docker info
Client: Docker Engine - Community
Version: 26.1.4
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.14.1
Path: /usr/libexec/docker/cli
plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.27.1
Path: /usr/libexec/docker/cli
plugins/docker-composeServer:
Containers: 2 #容器数量
Running: 2 #正在运⾏的容器
Paused: 0
Stopped: 0
Images: 3
Server Version: 26.1.4
Storage Driver: overlay2 # 存储驱动
Backing Filesystem: xfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json
file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init containerd version:
d2d58213f83a351ca8f528a95fbd145f5654e957
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 3.10.0-1160.119.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 972.1MiB
Name: docker001.yuanyu.zhangmin
ID: 7684bd62-67f2-48c8-a2ee-daaa649abf70
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://do.nark.eu.org/
https://dc.j8.work/
https://docker.m.daocloud.io/
https://dockerproxy.com/
https://docker.mirrors.ustc.edu.cn/ https://docker.nju.edu.cn/
Live Restore Enabled: false
[DEPRECATION NOTICE]: API is accessible on
http://0.0.0.0:2375 without encryption.
Access to the remote API is equivalent to
root access on the host. Refer
to the 'Docker daemon attack surface'
section in the documentation for
more information:
https://docs.docker.com/go/attack-surface/
In future versions this will be a hard failure
preventing the daemon from starting! Learn more
at: https://docs.docker.com/go/api-security/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@docker001 ~]# ls /var/lib/docker/buildkit containers engine-id image network
overlay2 plugins runtimes swarm tmp volumes
[root@docker001 ~]# tree -L 2 /var/lib/docker/
/var/lib/docker/
"## buildkit
$   "## cache.db
$   "## containerdmeta.db
$   "## content
$   "## executor
$   "## history.db
$   "## metadata_v2.db
$   "## net
$   %## snapshots.db
"## containers
$   "##
5ce068ef110b103c565602dcc7c4af66f91cd2b6ea8129af7a
be5383c4aa0f8d
$   %##
948f20e1ed4758e78759de8f9ce9b34a7f44c431bc8ead75b6
70e1a5b488654c
"## engine-id
"## image
$   %## overlay2
"## network
$   %## files
"## overlay2$   "##
0471ada2dce770506dd29557cd04ce8ee3f4a632a81f482ce0
e2b139d8251611
$   "##
109e3f2004911eabcd6934be32281c1ed9897b46de48a8960d
1253a668145126
$   "##
117fd8ba9ff0ed91d48cff774a1061baf9efe6fe4d63cdb14e
768bfd742a3f3b
$   "## 235zotit1cskmcglyr9nykhou
$   "## 2q24gwawlr1jvee48x9zrqxai
$   "##
332fbcc4b5175a6970ca7788db3898f9102f84f6a68029f57f
ccfbe2a3408729
$   "##
332fbcc4b5175a6970ca7788db3898f9102f84f6a68029f57f
ccfbe2a3408729-init
$   "## 3y08ei53ildl077di6t0xhvt4
$   "##
4e699a81c9752aa0e2182cb302c11af1f39093ee81f2c7cf1a
9ef7189feee839
$   "##
4e699a81c9752aa0e2182cb302c11af1f39093ee81f2c7cf1a
9ef7189feee839-init$   "##
561bbad3be962475eff729aa3d5240eb213176bae772cfe4e5
d45f22b123fb7a
$   "##
561bbad3be962475eff729aa3d5240eb213176bae772cfe4e5
d45f22b123fb7a-init
$   "##
56b9d2c60d83b8e72cd15975c63ebfbdd3e6055d49b3d739d7
5a1ff94e277dda
$   "##
6564c73ad543b723881b076fe387422b191cd48158811ce89b
aaa6406b284df4
$   "##
7711d9a14b6fc142ef00c96d7d9140628b60d01f00f253e584
80e4088b5434a4
$   "##
7a9653ab64da80a7fd2ffdb6cbac391b298c9df892db50d053
9f35682379023c
$   "##
8703d4e4fb30097919c7e5983aec21c548b188a3a4bee865dd
5043b948fe5c2d
$   "##
89bb8ec84e2069acba669fecb7ef2500a054652586c80e2e94
7173b5b369a834$   "##
a0f5901965932b6db0ec37cd31654532e08cac14e0b12b1897
090cdef1ed9a3d
$   "##
a0f5901965932b6db0ec37cd31654532e08cac14e0b12b1897
090cdef1ed9a3d-init
$   "##
a63d730255cb91be82e6c51cc677717728b45f4032e4e5e48b
0e2a9e5aa2deab
$   "##
a63d730255cb91be82e6c51cc677717728b45f4032e4e5e48b
0e2a9e5aa2deab-init
$   "## ah3i2ooqroom29dxbl7tfn7qq
$   "## backingFsBlockDev
$   "##
c8ee533075c8244596da864a555935839a9850b450b6687201
80802707a9a146
$   "##
c8ee533075c8244596da864a555935839a9850b450b6687201
80802707a9a146-init
$   "##
cca21d9c366100f059609ce466a8ffdd5e820407d89c1e89b2
154e0573b04b67
$   "##
e2bc5e84f80761a20c10b0d7a914141e912f63ed79266ef381
290c424bf40b1d$   "## el3ttxid0yg954kt85y798vze
$   "##
f77539952d704ff61e8983dd2db9e7998503d1e98ad3df4db9
bed32a7fd50903
$   "## gf94ym4xk3ow1tk39dihylvyd
$   "## hp0h9kwz0lhzvp1vitb7luhy3
$   "## kfjteefzg4mrc7959nj2au3le
$   "## kkg0d8n5rg51yksgbm2xxw8ou
$   "## l
$   "## mwd5hxe90l7liljg8pkaam3r6
$   "## nbxfcewpnxawtj825cu3xw3ph
$   "## ngvvz7u0xe1xgs82c1h0qspcm
$   "## on9ypo393wf86a8b1kuawmsez
$   "## pc9zeyl68k1ju2xvdiuv5sihd
$   "## phy7f7a1llvm8rsn7auwsj6iw
$   "## pi9f4xmuk60u70onzmz1q4r9c
$   "## pqyc1rcou6ddvbnygkrs68c3l
$   "## q09bzwofod6zhhhpttb9tpmbz
$   "## qazjj8ki0z9q206jga0sii0ru
$   "## sroxs9tw339wyo94pwle3llym
$   "## w09y9n8pqbfexzhk4ut61ktma
$   "## whbqjbm3dp1wrxtblscir4ywr
$   %## z5yoracg29fmorw6e99o4qshv
"## plugins
$   "## storage
$   %## tmp"## runtimes
"## swarm
"## tmp
%## volumes
"##
1652bd379334d5a944d0b40dde7b0fe944e3c043dc850ec171
8ccc9f52e31872
"## backingFsBlockDev
"##
c2dbff511839eeb4a788c15fc2414b826b89222555d27070ea
65467cb1ac26e1
%## metadata.db
69 directories, 9 files查看系统内核
[root@docker001 l]# uname -r
3.10.0-1160.119.1.el7.x86_64
查看⽂件系统
[root@docker001 l]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点
devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shmtmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101057 8809791
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101057 8809791
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101057 8809791
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged
新建⼀个⽂件之后 可⽤的节点减少⼀个
[root@docker001 ~]# touch 123.txt
[root@docker001 ~]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shm
tmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101058 8809790
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101058 8809790
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101058 8809790
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged
创建软连接之后,节点减少⼀个[root@docker001 ~]# ln -s 123.txt 123.lk
[root@docker001 ~]# df -i
⽂件系统 Inode 已⽤(I) 可⽤(I) 已⽤
(I)% 挂载点
devtmpfs 121445 390 121055
1% /dev
tmpfs 124432 1 124431
1% /dev/shm
tmpfs 124432 794 123638
1% /run
tmpfs 124432 16 124416
1% /sys/fs/cgroup
/dev/mapper/centos-root 8910848 101059 8809789
2% /
/dev/sda1 524288 333 523955
1% /boot
tmpfs 124432 1 124431
1% /run/user/0
overlay 8910848 101059 8809789
2%
/var/lib/docker/overlay2/a0f5901965932b6db0ec37cd3
1654532e08cac14e0b12b1897090cdef1ed9a3d/merged
overlay 8910848 101059 8809789
2%
/var/lib/docker/overlay2/c8ee533075c8244596da864a5
55935839a9850b450b668720180802707a9a146/merged在启动docker服务后会新建/var/lib/docker
[root@docker001 ~]# ls /var/lib/docker
ls: ⽆法访问/var/lib/docker: 没有那个⽂件或⽬录
[root@docker001 ~]# systemctl start docker.service
[root@docker001 ~]# ls /var/lib/docker
buildkit containers engine-id image network
overlay2 plugins runtimes swarm tmp volumes
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev l
拉取⼀个新镜像之后,就会在overlay2⽂件夹中保存新的⽂件[root@docker001 ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest:
sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534b
bdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34 l
[root@docker001 ~]#
查看⽂件保存位置[root@docker001 ~]# cd
/var/lib/docker/overlay2/ce54a04e45edb448429f2f7ad
b8a8a1d23379e300f8e7c1a98beb4512d932c34/
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]# ls
diff link
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]# ls diff/
bin etc lib lost+found mnt proc run srv
tmp var
dev home lib64 media opt root sbin sys
usr
[root@docker001
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34]#
创建容器后出现2个新的⽂件夹[root@docker001 ~]# docker run -it --name c0
centos:latest /bin/bash
[root@4c7f96d1a03e /]# [root@docker001 ~]#
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
查看容器⽬录[root@docker001 ~]# cd
/var/lib/docker/overlay2/e291e027242e013f682fe631b
83e89a90f9ba68fa1af92fda2fe4d9094f7b7eb
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# ls
diff link lower merged work
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# cat lower
l/LBSEYI2LHNHNIYE7AYQMOC6RBP:l/KQTNFI7JQXIRWB3PFKE
D2HRWJD[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]# ls merged/
bin etc lib lost+found mnt proc run srv
tmp var
dev home lib64 media opt root sbin sys
usr
[root@docker001
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb]#
在外⾯使⽤exec创建⼀个⽂件[root@docker001 ~]# docker exec 4c7f dd
if=/dev/zero of=/test bs=10M count=100
100+0 records in
100+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 2.7744
s, 378 MB/s
[root@docker001 ~]# ls
/var/lib/docker/overlay2/e291e027242e013f682fe631b
83e89a90f9ba68fa1af92fda2fe4d9094f7b7eb/merged/
bin etc lib lost+found mnt proc run srv
test usr
dev home lib64 media opt root sbin sys
tmp var
容器保存镜像和数据
查看容器挂载
容器被移除以后,这个⽂件就会被删除,stop不会删除
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDevce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
l
[root@docker001 ~]# docker stop c0
c0
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb
e291e027242e013f682fe631b83e89a90f9ba68fa1af92fda2
fe4d9094f7b7eb-init
l
[root@docker001 ~]# docker rm c0
c0
[root@docker001 ~]# ls /var/lib/docker/overlay2/
backingFsBlockDev
ce54a04e45edb448429f2f7adb8a8a1d23379e300f8e7c1a98
beb4512d932c34 l
[root@docker001 ~]#
创建私有仓库,在企业中分享项⽬
# 安装仓库镜像
[root@docker001 ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
930bdd4d222e: Pull complete
a15309931e05: Pull complete
6263fb9c821f: Pull complete
86c1d3af3872: Pull complete
a37b1bf6a96f: Pull complete
Digest:
sha256:12120425f07de11a1b899e418d4b0ea174c8d4d572d
45bdb640f93bc7ca06a3d
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
#查看新安装的镜像
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
registry latest cfb4d9904335 10 months
ago 25.4MB
centos latest 5d0da3dc9764 2 years ago
231MB# 创建挂载的⽬录
[root@docker001 ~]# mkdir /opt/dockeregistry
# 创建容器,映射端⼝,挂载⽂件
[root@docker001 ~]# docker run -d --name c1 -
p5000:5000 -v
/opt/dockeregistry/:/var/lib/registry
registry:latest
7ec28de22490aee02bd542ef22076f8ba746f7513cf96bf501
d817bc07b38f27
[root@docker001 ~]# docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
7ec28de22490 registry:latest "/entrypoint.sh
/etc…" 13 seconds ago Up 12 seconds
0.0.0.0:5000->5000/tcp, :::5000->5000/tcp c1
# 访问⽬录⻚
[root@docker001 ~]# curl
http://10.1.1.50:5000/v2/_catalog
{"repositories":[]}
# 创建仓库[root@docker001 ~]# vim /etc/docker/daemon.json
[root@docker001 ~]# cat /etc/docker/daemon.json
{
"insecure-registries":[
"http://10.1.1.50:5000"
],
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
],
"hosts": [
"tcp://0.0.0.0:2375",
"unix:///var/run/docker.sock"
]
}
# 重启docker服务[root@docker001 ~]# systemctl restart
docker.service
# 查看镜像
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
registry latest cfb4d9904335 10 months
ago 25.4MB
centos latest 5d0da3dc9764 2 years ago
231MB
# 为要上传的镜像添加标记
[root@docker001 ~]# docker tag centos:latest
10.1.1.50:5000/centos:v0
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
registry latest cfb4d9904335
10 months ago 25.4MB
10.1.1.50:5000/centos v0 5d0da3dc9764 2
years ago 231MB
centos latest 5d0da3dc9764 2
years ago 231MB10.1.1.50/centos v0 5d0da3dc9764 2
years ago 231MB
[root@docker001 ~]# docker push
10.1.1.50:5000/centos:v0
The push refers to repository
[10.1.1.50:5000/centos]
Get "http://10.1.1.50:5000/v2/": dial tcp
10.1.1.50:5000: connect: connection refused
[root@docker001 ~]# docker start c1
c1
[root@docker001 ~]# docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
7ec28de22490 registry:latest "/entrypoint.sh
/etc…" 16 minutes ago Up 4 seconds
0.0.0.0:5000->5000/tcp, :::5000->5000/tcp c1
[root@docker001 ~]# docker push
10.1.1.50:5000/centos:v0
The push refers to repository
[10.1.1.50:5000/centos]
74ddd0ec08fa: Pushed
v0: digest:
sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c8386
3037fa3aab063a7fdb9dc size: 529
[root@docker001 ~]# ls /opt/1.png assets dist
index.html
2.png containerd dockeregistry
nohup.out
application.properties cvloume favicon.ico
Project_ExamSystem-V1.0.0.war
[root@docker001 ~]# ls /opt/dockeregistry/
docker
[root@docker001 ~]# ls /opt/dockeregistry/docker/
registry
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/
v2
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/v2/
blobs repositories
[root@docker001 ~]# ls
/opt/dockeregistry/docker/registry/v2/repositories
/
centos
[root@docker001 ~]#1.拉取registry
docker pull registry
2.创建挂载⽬录
mkdir /regist
3.启动容器,映射端⼝,挂载⽬录
docker run -d --name c0 -v
/regist/:/var/lib/rigistry/ -p5000:5000
registry:latest
4.访问仓库
curl http://192.168.71.50:5000/v2/_catelog
5.配置pull和push,修改daemon.jsonvim /etc/docker/daemon.json
{
.....,
"insecure-registries":[
"http://192.168.71.50:5000"
]
}
:wq
6.修改了配置⽂件,重启docker服务
systemctl restart docker
7.启动registry容器
docker start r1
curl localhost:5000/v2/_catalog

这篇关于云计算day33的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1113611

相关文章

poj 1113 凸包+简单几何计算

题意: 给N个平面上的点,现在要在离点外L米处建城墙,使得城墙把所有点都包含进去且城墙的长度最短。 解析: 韬哥出的某次训练赛上A出的第一道计算几何,算是大水题吧。 用convexhull算法把凸包求出来,然后加加减减就A了。 计算见下图: 好久没玩画图了啊好开心。 代码: #include <iostream>#include <cstdio>#inclu

uva 1342 欧拉定理(计算几何模板)

题意: 给几个点,把这几个点用直线连起来,求这些直线把平面分成了几个。 解析: 欧拉定理: 顶点数 + 面数 - 边数= 2。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#inc

uva 11178 计算集合模板题

题意: 求三角形行三个角三等分点射线交出的内三角形坐标。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#include <stack>#include <vector>#include <

XTU 1237 计算几何

题面: Magic Triangle Problem Description: Huangriq is a respectful acmer in ACM team of XTU because he brought the best place in regional contest in history of XTU. Huangriq works in a big compa

音视频入门基础:WAV专题(10)——FFmpeg源码中计算WAV音频文件每个packet的pts、dts的实现

一、引言 从文章《音视频入门基础:WAV专题(6)——通过FFprobe显示WAV音频文件每个数据包的信息》中我们可以知道,通过FFprobe命令可以打印WAV音频文件每个packet(也称为数据包或多媒体包)的信息,这些信息包含该packet的pts、dts: 打印出来的“pts”实际是AVPacket结构体中的成员变量pts,是以AVStream->time_base为单位的显

计算数组的斜率,偏移,R2

模拟Excel中的R2的计算。         public bool fnCheckRear_R2(List<double[]> lRear, int iMinRear, int iMaxRear, ref double dR2)         {             bool bResult = true;             int n = 0;             dou

GPU 计算 CMPS224 2021 学习笔记 02

并行类型 (1)任务并行 (2)数据并行 CPU & GPU CPU和GPU拥有相互独立的内存空间,需要在两者之间相互传输数据。 (1)分配GPU内存 (2)将CPU上的数据复制到GPU上 (3)在GPU上对数据进行计算操作 (4)将计算结果从GPU复制到CPU上 (5)释放GPU内存 CUDA内存管理API (1)分配内存 cudaErro

Java - BigDecimal 计算分位(百分位)

日常开发中,如果使用数据库来直接查询一组数据的分位数,就比较简单,直接使用对应的函数就可以了,例如:         PERCENT_RANK() OVER(PARTITION BY 分组列名 ORDER BY 目标列名) AS 目标列名_分位数         如果是需要在代码逻辑部分进行分位数的计算,就需要我们自己写一个工具类来支持计算了 import static ja

OpenStack离线Train版安装系列—2计算节点-环境准备

本系列文章包含从OpenStack离线源制作到完成OpenStack安装的全部过程。 在本系列教程中使用的OpenStack的安装版本为第20个版本Train(简称T版本),2020年5月13日,OpenStack社区发布了第21个版本Ussuri(简称U版本)。 OpenStack部署系列文章 OpenStack Victoria版 安装部署系列教程 OpenStack Ussuri版

新一代车载(E/E)架构下的中央计算载体---HPC软件架构简介

老规矩,分享一段喜欢的文字,避免自己成为高知识低文化的工程师: 屏蔽力是信息过载时代一个人的特殊竞争力,任何消耗你的人和事,多看一眼都是你的不对。非必要不费力证明自己,无利益不试图说服别人,是精神上的节能减排。 无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事.而不是让内心的烦躁、焦虑、毁掉你本就不多的热情和定力。 时间不知不觉中,快要来到夏末秋初。一年又过去了一大半,成