docker技术

目录

一、docker安装

二、docker操作

三、dockerfile创建PHP镜像

四、docker安装tomcat

五、docker registry的搭建与使用


一、docker安装

[root@libvirt ~]# yum install docker -y 

//查看

[root@libvirt ~]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc docker-runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 8891bca22c049cd2dcf13ba2438c0bac8d7f3343 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  WARNING: You're not using the default seccomp profile
  Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-1160.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 3.682 GiB
Name: libvirt
ID: BMCR:ZJF7:6DU7:5N7I:YZE6:KIGK:DWYG:7GME:TM6Z:D4K4:4I2O:F2QU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)
//配置镜像加速(注册并登录阿里云)

 

进入后有个操作文档

[root@libvirt ~]# mkdir -p /etc/docker
[root@libvirt ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://xxxxxx.aliyuncs.com"]
> }
> EOF

//重启服务

[root@libvirt ~]# systemctl daemon-reload
[root@libvirt ~]# systemctl restart docker

二、docker操作

//启动

[root@libvirt ~]# systemctl start docker

//获取ubuntu镜像

[root@libvirt ~]# docker pull ubuntu

Using default tag: latest
Trying to pull repository docker.io/library/ubuntu ... 
latest: Pulling from docker.io/library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for docker.io/ubuntu:latest
//查看镜像

[root@libvirt ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/ubuntu    latest              ba6acccedd29        12 months ago       72.8 MB
//运行ubuntu

[root@libvirt ~]# docker run -it ba6acccedd29 bash
root@ae35f70599eb:/# 
//以特定格式显示

[root@libvirt ~]# docker images -q
ba6acccedd29
[root@libvirt ~]# docker images --format "{{.ID}}:{{.Repository}}"
ba6acccedd29:docker.io/ubuntu
//查找镜像

[root@libvirt ~]# docker search centos
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/centos                                       The official build of CentOS.                   7330      [OK]       
docker.io   docker.io/kasmweb/centos-7-desktop                     CentOS 7 desktop for Kasm Workspaces            24                   
docker.io   docker.io/couchbase/centos7-systemd                    centos7-systemd images with additional deb...   4                    [OK]
docker.io   docker.io/continuumio/centos5_gcc5_base                                                                3                    
docker.io   docker.io/dokken/centos-7                              CentOS 7 image for kitchen-dokken               3                    
docker.io   docker.io/dokken/centos-stream-8                                                                       2                    
docker.io   docker.io/dokken/centos-stream-9                                                                       2                    
docker.io   docker.io/spack/centos6                                CentOS 6 with Spack preinstalled                1                    
docker.io   docker.io/spack/centos7                                CentOS 7 with Spack preinstalled                1                    
docker.io   docker.io/bitnami/centos-base-buildpack                Centos base compilation image                   0                    [OK]
docker.io   docker.io/bitnami/centos-extras-base                                                                   0                    
docker.io   docker.io/corpusops/centos                             centos corpusops baseimage                      0                    
docker.io   docker.io/corpusops/centos-bare                        https://github.com/corpusops/docker-images/     0                    
docker.io   docker.io/couchbase/centos-69-sdk-build                                                                0                    
docker.io   docker.io/couchbase/centos-69-sdk-nodevtoolset-build                                                   0                    
docker.io   docker.io/couchbase/centos-70-sdk-build                                                                0                    
docker.io   docker.io/couchbase/centos-72-java-sdk                                                                 0                    
docker.io   docker.io/couchbase/centos-72-jenkins-core                                                             0                    
docker.io   docker.io/datadog/centos-i386                                                                          0                    
docker.io   docker.io/dokken/centos-5                              EOL DISTRO: For use with kitchen-dokken, B...   0                    
docker.io   docker.io/dokken/centos-6                              CentOS 6 image for kitchen-dokken               0                    
docker.io   docker.io/dokken/centos-8                              CentOS 8 image for kitchen-dokken               0                    
docker.io   docker.io/fnndsc/centos-python3                        Source for a slim Centos-based Python3 ima...   0                    [OK]
docker.io   docker.io/spack/centos-stream                                                                          0                    
docker.io   docker.io/ustclug/centos                               Official CentOS Image with USTC Mirror          0                    
//删除镜像

[root@libvirt ~]# docker rmi -f ba6acccedd29
Untagged: docker.io/ubuntu:latest
Untagged: docker.io/ubuntu@sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Deleted: sha256:ba6acccedd2923aee4c2acc6a23780b14ed4b8a5fa4e14e252a23b846df9b6c1
[root@libvirt ~]# docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

//运行指定名称的容器

[root@libvirt ~]# docker run -i -d --name ubuntu ubuntu:latest /bin/bash
Unable to find image 'ubuntu:latest' locally
Trying to pull repository docker.io/library/ubuntu ... 
latest: Pulling from docker.io/library/ubuntu
7b1a6ab2e44d: Already exists 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288
Status: Downloaded newer image for docker.io/ubuntu:latest
803e0ebbaf88e04478375d1bc81bd948a9eb42454d264f3e72aa451c8f67b509
//查看正在运行的容器

[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
803e0ebbaf88        ubuntu:latest       "/bin/bash"         About a minute ago   Up About a minute                       ubuntu
//停止容器

[root@libvirt ~]# docker stop 803e0ebbaf88
803e0ebbaf88

[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
//查看所有容器

[root@libvirt ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                        PORTS               NAMES
803e0ebbaf88        ubuntu:latest       "/bin/bash"         4 minutes ago       Exited (137) 42 seconds ago                       ubuntu
ae35f70599eb        ba6acccedd29        "bash"              17 minutes ago      Exited (0) 17 minutes ago                         frosty_blackwell

//开启并进入容器内部

[root@libvirt ~]# docker start 803e0ebbaf88
803e0ebbaf88
[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
803e0ebbaf88        ubuntu:latest       "/bin/bash"         18 minutes ago      Up 31 seconds                           ubuntu
//使用attach进入容器,退出后容器不再运行

[root@libvirt ~]# docker attach 803e0ebbaf88

root@803e0ebbaf88:/# exit
exit

[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

//使用 exec进入容器,退出后容器依旧运行

[root@libvirt ~]# docker exec -it 803e0ebbaf88 bash
root@803e0ebbaf88:/# exit
exit

[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
803e0ebbaf88        ubuntu:latest       "/bin/bash"         24 minutes ago      Up 6 minutes                            ubuntu
//创建守护式容器

[root@libvirt ~]# docker run -d --name ubuntu_daemon ubuntu:latest /bin/bash -c "while true;do echo hello world,sleep 1;done"
bd4ad1a932b7fd5b16a064e90844ae6a37090d9247f01d074e83d05ee476fc4e
[root@libvirt ~]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
bd4ad1a932b7        ubuntu:latest       "/bin/bash -c 'whi..."   7 seconds ago       Up 6 seconds                            ubuntu_daemon

//查看日志,循环打印hello world
[root@libvirt ~]# docker logs -f -t ubuntu_daemon 
2022-10-16T11:59:38.805898000Z hello world,sleep 1
2022-10-16T11:59:38.806004000Z hello world,sleep 1
2022-10-16T11:59:38.806108000Z hello world,sleep 1
2022-10-16T11:59:38.806187000Z hello world,sleep 1
.........

//查看容器内进程

[root@libvirt ~]# docker top ubuntu_daemon
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                3794                3778                8                   19:59               ?                   00:00:15            /bin/bash -c while true;do echo hello world,sleep 1;done
//统计信息

[root@libvirt ~]# docker stats 

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
bd4ad1a932b7        2.23%               248 KiB / 3.682 GiB   0.01%               656 B / 656 B       0 B / 0 B           1

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
bd4ad1a932b7        12.49%              248 KiB / 3.682 GiB   0.01%               656 B / 656 B       0 B / 0 B           1

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
bd4ad1a932b7        12.49%              248 KiB / 3.682 GiB   0.01%               656 B / 656 B       0 B / 0 B           1
//导出快照

[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
bd4ad1a932b7        ubuntu:latest       "/bin/bash -c 'whi..."   5 minutes ago       Up 5 minutes                            ubuntu_daemon
[root@libvirt ~]# docker  export  bd4ad1a932b7 > ubuntu.tar
[root@libvirt ~]# ll ubuntu.tar 
-rw-r--r-- 1 root root 75158016 10月 16 20:05 ubuntu.tar

//导入快照

[root@libvirt ~]# cat ubuntu.tar |docker import - test/ubuntu:v1.0
sha256:6521d2abd80ab425c0aeb8b59161ca455e05601ab7782b5acdddbfb07c6eb653
[root@libvirt ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test/ubuntu         v1.0                6521d2abd80a        9 seconds ago       72.8 MB
docker.io/ubuntu    latest              ba6acccedd29        12 months ago       72.8 MB
//查看具体配置信息

root@libvirt ~]# docker inspect bd4ad1a932b7
[
    {
        "Id": "bd4ad1a932b7fd5b16a064e90844ae6a37090d9247f01d074e83d05ee476fc4e",
        "Created": "2022-10-16T11:59:38.617743502Z",
        "Path": "/bin/bash",
        "Args": [
            "-c",
            "while true;do echo hello world,sleep 1;done"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 3794,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-10-16T11:59:38.812693891Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
.......

//以特定格式显示容器信息,例如查看容器IP

[root@libvirt ~]# docker inspect --format='{{.NetworkSettings.IPAddress}}'  bd4ad1a932b7
172.17.0.2

三、dockerfile创建PHP镜像

//安装数据库服务

[root@libvirt ~]# yum install mariadb-server -y

//启动
[root@libvirt ~]# systemctl start  mariadb

//配置

[root@libvirt ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y       //输入密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
//登录数据库

[root@libvirt ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

//允许用户远程登录

MariaDB [(none)]> grant all privileges on *.* to 'testuser'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

//创建数据库和表

MariaDB [(none)]> create database php_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create table php_db.student(name char(20) not null,age int not null,sex char(20) not null) default charset=utf8;
Query OK, 0 rows affected (0.02 sec)
//插入数据

MariaDB [(none)]> insert into php_db.student values('zhangsna',22,'man'),('lisi',21,'man'),('wangwu',18,'women');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0
MariaDB [(none)]> Ctrl-C -- exit!
Aborted
//创建工作目录

[root@libvirt ~]# mkdir /opt/php
[root@libvirt ~]# cd /opt/php/
[root@libvirt php]# touch Dockerfile
//编写run.sh

[root@libvirt php]# vim run.sh

#!/bin/bash
httopd
while true
do
 sleep 1000
done

//编写test.php

[root@libvirt php]# vim test.php

<?php
$con=mysql_connect(getenv("MYSQL_ADDR"),getenv("MYSQL_USER"),getenv("MYSQL_PASS"));
if(!$con)
{
    die('Could not connect:'.mysql_error());
}
mysql_select_db("php_db",$con);
$result=mysql_query("SELECT * FROM student");
echo "<table border='1'>
<tr>
<th>NAME</th>
<th>AGE</th>
<th>SEX</th>
</tr>";
while ($row=mysql_fetch_array($result))
{
    echo "<tr>";
    echo "<td>".$row['name']."</td>";
    echo "<td>".$row['age']."</td>";
    echo "<td>".$row['sex']."</td>";
    echo "</tr>";
}
    echo "</table>";
mysql_close($con);
?>

//编写Dockerfile 

[root@libvirt php]# vim Dockerfile 

FROM centos:7
MAINTAINER James "james@example.com"
WORKDIR /root/
RUN yum install -y php php-mysql
RUN mkdir -p /var/log/httpd
RUN mkdir -p /var/www/html
ENV MYSQL_ADDR 192.168.100.145
ENV MYSQL_USER testuser
ENV MYSQL_PASS 123456
ENV TERM liunx
ENV LC_ALL en_US.UTF-8
COPY test.php /var/www/html/test.php
EXPOSE 80
COPY run.sh /root/run.sh
RUN chmod u+x /root/run.sh
CMD /root/run.sh

//构建新镜像

[root@libvirt php]# docker build -t james/php_web .

Sending build context to Docker daemon 4.608 kB
Step 1/16 : FROM centos:7
Trying to pull repository docker.io/library/centos ... 
7: Pulling from docker.io/library/centos
2d473b07cdd5: Pull complete 

..........
Successfully built 66732245854f

//查看镜像

[root@libvirt php]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
james/php_web       latest              66732245854f        About a minute ago   441 MB
test/ubuntu         v1.0                6521d2abd80a        14 hours ago         72.8 MB
docker.io/ubuntu    latest              ba6acccedd29        12 months ago        72.8 MB
docker.io/centos    7                   eeb6ee3f44bd        13 months ago        204 MB
docker.io/centos    latest              5d0da3dc9764        13 months ago        231 MB

四、docker安装tomcat

//拉取镜像

[root@libvirt ~]# docker pull tomcat
Using default tag: latest
Trying to pull repository docker.io/library/tomcat ... 
latest: Pulling from docker.io/library/tomcat
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
668f6fcc5fa5: Pull complete 
dc120c3e0290: Pull complete 
8f7c0eebb7b1: Pull complete 
77b694f83996: Pull complete 
0f611256ec3a: Pull complete 
4f25def12f23: Pull complete 
Digest: sha256:9dee185c3b161cdfede1f5e35e8b56ebc9de88ed3a79526939701f3537a52324
Status: Downloaded newer image for docker.io/tomcat:latest
[root@libvirt ~]# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
james/php_web                        latest              66732245854f        3 days ago          441 MB
test/ubuntu                          v1.0                6521d2abd80a        3 days ago          72.8 MB
docker.io/tomcat                     latest              fb5657adc892        10 months ago       680 MB
docker.io/registry                   latest              b8604a3fe854        11 months ago       26.2 MB
docker.io/ubuntu                     latest              ba6acccedd29        12 months ago       72.8 MB
docker.io/centos                     7                   eeb6ee3f44bd        13 months ago       204 MB
//运行

[root@libvirt ~]# docker run  -p 8080:8080 --name  tomcat  -d docker.io/tomcat
74badb4f6bc6f21905f2ec82a62c2d16da9eea10de428531dbd45265b4140736
[root@libvirt ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
74badb4f6bc6        docker.io/tomcat    "catalina.sh run"   8 seconds ago       Up 7 seconds        0.0.0.0:8080->8080/tcp   tomcat
//访问猫首页,发现是404

//关闭防火墙

[root@libvirt ~]# systemctl stop firewalld
[root@libvirt ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

//进入容器内部

 [root@libvirt ~]# docker exec -it 74badb4f6bc6 bash
root@74badb4f6bc6:/usr/local/tomcat# ls -l
total 132
-rw-r--r-- 1 root root 18994 Dec  2  2021 BUILDING.txt
-rw-r--r-- 1 root root  6210 Dec  2  2021 CONTRIBUTING.md
-rw-r--r-- 1 root root 60269 Dec  2  2021 LICENSE
-rw-r--r-- 1 root root  2333 Dec  2  2021 NOTICE
-rw-r--r-- 1 root root  3378 Dec  2  2021 README.md
-rw-r--r-- 1 root root  6905 Dec  2  2021 RELEASE-NOTES
-rw-r--r-- 1 root root 16517 Dec  2  2021 RUNNING.txt
drwxr-xr-x 2 root root  4096 Dec 22  2021 bin
drwxr-xr-x 1 root root    22 Oct 20 07:03 conf
drwxr-xr-x 2 root root  4096 Dec 22  2021 lib
drwxrwxrwx 1 root root    80 Oct 20 07:03 logs
drwxr-xr-x 2 root root   159 Dec 22  2021 native-jni-lib
drwxrwxrwx 2 root root    30 Dec 22  2021 temp
drwxr-xr-x 2 root root     6 Dec 22  2021 webapps
drwxr-xr-x 7 root root    81 Dec  2  2021 webapps.dist
drwxrwxrwx 2 root root     6 Dec  2  2021 work

//查看webapps为空
root@74badb4f6bc6:/usr/local/tomcat# ls -l  webapps
total 0
//修改并退出

root@74badb4f6bc6:/usr/local/tomcat# rm -rf  webapps
root@74badb4f6bc6:/usr/local/tomcat# mv webapps.dist webapps
root@74badb4f6bc6:/usr/local/tomcat# exit
//重新进入猫页面

 

 

五、docker registry的搭建与使用

//拉取registry镜像

[root@libvirt php]# docker pull registry

//查看镜像

[root@libvirt php]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE james/php_web latest 66732245854f 13 minutes ago 441 MB test/ubuntu v1.0 6521d2abd80a 15 hours ago 72.8 MB docker.io/registry latest b8604a3fe854 11 months ago 26.2 MB docker.io/ubuntu latest ba6acccedd29 12 months ago 72.8 MB docker.io/centos 7 eeb6ee3f44bd 13 months ago 204 MB docker.io/centos latest

5d0da3dc9764 13 months ago 231 MB

//编辑配置文件

[root@libvirt ~]# vim /etc/sysconfig/docker
添加

ADD_REGISTRY='--add-registry 192.168.100.145:5000'
INSECURE_REGISTRY='--insecure-registry 192.168.100.145:5000'
OPTIONS='-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock'

//创建本地文件夹

[root@libvirt ~]# mkdir -p /data/registry/

//启动端口
[root@libvirt ~]# docker run -itd -p 5000:5000 -v /data/registry:/var/lib/registry docker.io/registry
3e56f08ec4ce4d4df3c493236e3fc518b9fdaf3a8d79d677dd9956ea89d8f630

//查看端口

[root@libvirt ~]# netstat -tnlp|grep -w 5000
tcp6       0      0 :::5000                 :::*                    LISTEN      2978/docker-proxy-c 

//上传到私有仓库
[root@libvirt ~]# docker push james/php_web
The push refers to a repository [192.168.100.145:5000/james/php_web]
919635e708d0: Pushed 
1590c568c775: Pushed 
86dfd8ae0481: Pushed 
d4958f636666: Pushed 
174f56854903: Pushed 
latest: digest: sha256:36ad2ad8907473c565a79b72355bb7a031396d9c6decd1e3ef3b15a88eb18595 size: 1362
//获取私有仓库镜像

[root@libvirt ~]# docker pull james/php_web:latest 
Trying to pull repository 192.168.100.145:5000/james/php_web ... 
sha256:36ad2ad8907473c565a79b72355bb7a031396d9c6decd1e3ef3b15a88eb18595: Pulling from 192.168.100.145:5000/james/php_web
Digest: sha256:36ad2ad8907473c565a79b72355bb7a031396d9c6decd1e3ef3b15a88eb18595
Status: Downloaded newer image for 192.168.100.145:5000/james/php_web:latest
//查看仓库中的镜像

[root@libvirt ~]# curl http://192.168.100.145:2375/images/json |python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3208    0  3208    0     0   685k      0 --:--:-- --:--:-- --:--:--  783k
......

//查看仓库结点容器列表

[root@libvirt ~]# curl http://192.168.100.145:2375/containers/json |python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1011  100  1011    0     0   854k      0 --:--:-- --:--:-- --:--:--  987k
[
    {
        "Command": "/entrypoint.sh /etc/docker/registry/config.yml",
        "Created": 1666229250,
        "HostConfig": {
            "NetworkMode": "default"
        },
.........

//查看镜像仓库已有镜像名称

[root@libvirt ~]# curl http://192.168.100.145:5000/v2/_catalog
{"repositories":["james/php_web"]}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清风--明月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值