Docker 入门流程

基础的docker基本命令

docker启动命令

[root@localhost ~]# systemctl start docker

查询docker 命令帮助

[root@localhost ~]# docker --help

查看镜像

[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
mysql         5.7       c20987f18b13   5 months ago   448MB
mysql         latest    3218b38490ce   5 months ago   516MB
hello-world   latest    feb5d9fea6a5   7 months ago   13.3kB

docker 搜索命令 ( 它会去镜像地址去搜索)

[root@localhost ~]# docker search mysql
NAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                          MySQL is a widely used, open-source relation…   12606     [OK]       
mariadb                        MariaDB Server is a high performing open sou…   4843      [OK]       
percona                        Percona Server is a fork of the MySQL relati…   576       [OK]       
phpmyadmin                     phpMyAdmin - A web interface for MySQL and M…   542       [OK]       
bitnami/mysql                  Bitnami MySQL Docker Image                      71                   [OK]
linuxserver/mysql-workbench                                                    36                   
linuxserver/mysql              A Mysql container, brought to you by LinuxSe…   35                   
ubuntu/mysql                   MySQL open source fast, stable, multi-thread…   33                   
circleci/mysql                 MySQL is a widely used, open-source relation…   26                   
google/mysql                   MySQL server for Google Compute Engine          21                   [OK]
rapidfort/mysql                RapidFort optimized, hardened image for mysql   12                   
vmware/harbor-db               Mysql container for Harbor                      10                   
bitnami/mysqld-exporter                                                        3                    
ibmcom/mysql-s390x             Docker image for mysql-s390x                    2                    
nasqueron/mysql                                                                1                    [OK]
newrelic/mysql-plugin          New Relic Plugin for monitoring MySQL databa…   1                    [OK]
vitess/mysqlctld               vitess/mysqlctld                                1                    [OK]
cimg/mysql                                                                     0                    
mirantis/mysql                                                                 0                    
drud/mysql-local-57            ddev mysql local container                      0                    
drud/mysql-docker-local-57     This repo has been deprecated, new tags are …   0                    
drud/mysql                                                                     0                    
drud/mysql-docker-local        docker containers for local womysql rk          0                    [OK]
docksal/mysql                  MySQL service images for Docksal - https://d…   0                    
silintl/mysql-backup-restore   Simple docker image to perform mysql backups…   0                    [OK]

docker pull 下载镜像

[root@localhost ~]# docker pull mysql
Using default tag: latest   		  	 # 如果不写tag. 默认就是latest
latest: Pulling from library/mysql
72a69066d2fe: Pull complete     		 # 分层下载,docker imager 的核心 联合文件系统
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
688ba7d5c01a: Pull complete 
00e060b6d11d: Pull complete 
1c04857f594f: Pull complete 
4d7cfa90e6ea: Pull complete 
e0431212d27d: Pull complete 
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709  #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest     #真实地址


# 等价于它 以下命令等价
docker pull mysql
docker pull docker.io/library/mysql:latest   

# 指定版本下载
[root@localhost ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
72a69066d2fe: Already exists     #上面已经下载过的mysql镜像,这一次可以共用,所以表示已存在
93619dbc5b36: Already exists 
99da31dd6142: Already exists 
626033c43d70: Already exists 
37d5d7efb64e: Already exists 
ac563158d721: Already exists 
d2ba16033dad: Already exists 
0ceb82207cd7: Pull complete 
37f2405cae96: Pull complete 
e2482e017e53: Pull complete 
70deed891d42: Pull complete 
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

docker rmi 删除镜像

# 查看已有的镜像
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
mysql         5.7       c20987f18b13   5 months ago   448MB
mysql         latest    3218b38490ce   5 months ago   516MB
hello-world   latest    feb5d9fea6a5   7 months ago   13.3kB

 # 根据镜像的id进行删除
[root@localhost ~]# docker rmi -f c20987f18b13  
Untagged: mysql:5.7
Untagged: mysql@sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Deleted: sha256:c20987f18b130f9d144c9828df630417e2a9523148930dc3963e9d0dab302a76
Deleted: sha256:6567396b065ee734fb2dbb80c8923324a778426dfd01969f091f1ab2d52c7989

# 查看镜像,删除成功
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
mysql         latest    3218b38490ce   5 months ago   516MB
hello-world   latest    feb5d9fea6a5   7 months ago   13.3kB

# 查询出所有镜像后进行递归删除
[root@localhost ~]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Deleted: sha256:3218b38490cec8d31976a40b92e09d61377359eab878db49f025e5d464367f3b
Untagged: hello-world:latest
Untagged: hello-world@sha256:80f31da1ac7b312ba29d65080fddf797dd76acfb870e677f390d5acba9741b17
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412

容器命令

说明:我们有了镜像才可以创建容器,linux,下载一个centos镜像来测试学习

[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos

# 查看镜像, 镜像已经下载成功
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
centos       latest    5d0da3dc9764   8 months ago   231MB

1、新建容器并启动

docker run [可选参数] image    # 可选参数使用 docker run --help  命令查看有哪些

# 参数说明
--name="name"	容器名字 tomcat01   tomcat02  用来区分容器
-d 			后台方式运行 
-it			使用交互方式运行,进入容器查看内容
-p				指定容器的端口 -p 8080:8080\
	-p 主机端口:容器端口(常用)
	-p 容器端口
-p	随机指定端口

	 		
测试:
启动容器并给名字 为 it
[root@localhost ~]# docker run -it centos /bin/bash  	
[root@317beaac0681 /]# 					
表明已经进入到容器了

Docker 入门流程_第1张图片

查看启动的容器内部, 可以看出这个容器内容跟普通的容器没啥区别
[root@317beaac0681 /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 

退出容器

exit   # 容器停止运行并退出
ctrl + p + q  # 容器不停止退出

[root@317beaac0681 /]# exit    # 容器停止运行并退出

# ctrl + P + Q  # 容器不停止退出 (在键盘的大写模式下按这几个键)
[root@4cac2196aa2e /]# [root@localhost ~]# docker ps 
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS              PORTS     NAMES
4cac2196aa2e   centos    "/bin/bash"   13 seconds ago       Up 10 seconds                 peaceful_carver
64efab6e12e5   centos    "/bin/bash"   About a minute ago   Up About a minute             objective_jackson

列出所有运行的容器

# docker ps 命令 
-a			# 列出当前正在运行的容器(默认容器),顺带带出历史运行过的容器
-n=?		# 只显示最近创建的容器
-q			# 只显示容器的编号

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                      PORTS     NAMES
3bd0aed6e189   centos         "/bin/bash"   45 seconds ago   Exited (0) 17 seconds ago             hopeful_williams
598addfa8720   centos         "/bin/bash"   5 hours ago      Exited (0) 5 hours ago                quirky_agnesi
317beaac0681   centos         "/bin/bash"   5 hours ago      Exited (130) 5 hours ago              fervent_lalande
83c174518303   feb5d9fea6a5   "/hello"      46 hours ago     Exited (0) 46 hours ago               thirsty_davinci
204a0f5e6da0   feb5d9fea6a5   "/hello"      46 hours ago     Exited (0) 46 hours ago               clever_archimedes		

 docker ps 
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS              PORTS     NAMES
4cac2196aa2e   centos    "/bin/bash"   13 seconds ago       Up 10 seconds                 peaceful_carver
64efab6e12e5   centos    "/bin/bash"   About a minute ago   Up About a minute             objective_jackson

删除容器

docker rm 容器id		# 根据容器id删除容器(不能删除正在运行的容器,要强制删除利用 rm -f)
docker rm -f $(docker ps -aq)	# 删除所有容器
docker ps -a -q|xargs docker rm	# 删除所有容器
下面是列子:

# 由于rm 容器id 不能删除正在运行的容器而导致报错
[root@localhost ~]# docker rm 4cac2196aa2e
Error response from daemon: You cannot remove a running container 4cac2196aa2e1df5d16f987c560d3dd81dea7cfa1bdb362cc4e4150856421d0b. Stop the container before attempting removal or force remove
[root@localhost ~]# docker ps -aq
4cac2196aa2e
64efab6e12e5
3bd0aed6e189
598addfa8720
317beaac0681
83c174518303
204a0f5e6da0

# rm -f 即可删除正在运行的容器 $(docker ps -aq): 查询出所有正在运行的容器
[root@localhost ~]# docker rm -f $(docker ps -aq)
4cac2196aa2e
64efab6e12e5
3bd0aed6e189
598addfa8720
317beaac0681
83c174518303
204a0f5e6da0
[root@localhost ~]# docker ps -aq		
[root@localhost ~]# 				# 可以看到,容器都被删除掉了

启动和停止容器的操作

docker start 容器id		# 启动容器
docker restart 容器id	# 重启容器
docker stop 容器id		# 停止 当前正在运行的容器
docker kill 			# 强制停止当前容器

下面是例子(需要有历史运行过的容器,才可以使用以上四条命令):

# 先运行一个容器(这里的目的为了能找到历史运行容器id,否则无法使用上面的方式启动容器)
[root@localhost ~]# docker run -it centos /bin/bash   

# 把该容器退出
[root@00faae8b4bf2 /]# exit
exit

# 查看当前正在运行的容器(为空)
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

# 查看历史运行过的容器(可以看到 容器id=00faae8b4bf2。有了该容器id 就可以用以上命令启动或者停止容器了)
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS                          PORTS     NAMES
00faae8b4bf2   centos    "/bin/bash"   19 seconds ago       Exited (127) 8 seconds ago                suspicious_meninsky
1581a1d0cf0a   centos    "/bin/bash"   About a minute ago   Exited (0) About a minute ago             serene_bouman

# 使用docker start 容器id 命令启动容器
[root@localhost ~]# docker start 00faae8b4bf2
00faae8b4bf2
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS         PORTS     NAMES
00faae8b4bf2   centos    "/bin/bash"   45 seconds ago   Up 4 seconds             suspicious_meninsky

# 使用docker stop 容器id 停止容器
[root@localhost ~]# docker stop 00faae8b4bf2
00faae8b4bf2
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# 

常用的其他docker 命令

后台启动容器

注意: 该条命令启动容器后,使用docker ps 查看,会发现该容器停止了
原因: docker 容器使用后台运行,就必须要有一个前台的进程,docker 发现没有应用,就会自动停止
有使用容器就装了一个nginx ,此时容器启动后,发现自己没有提供服务,就会立刻停止,就是没有程序了

# docker run -d 镜像名

查看日志

docker logs -f -t --tail [要显示的日志条数] 容器id 
# 自己编写一段shell脚本,循环打印一句话(为了查看日志)
[root@localhost ~]# docker run -d centos /bin/sh -c "while true;do echo chenxiansheng;sleep 1;done"
3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
3926294a2cca   centos    "/bin/sh -c 'while t…"   5 seconds ago   Up 4 seconds             fervent_torvalds

# 查看日志命令
[root@localhost ~]# docker logs -t -f --tail 5 3926294a2cca
2022-05-22T06:56:16.970217803Z chenxiansheng
2022-05-22T06:56:17.983250772Z chenxiansheng
2022-05-22T06:56:18.994815474Z chenxiansheng
2022-05-22T06:56:19.998974466Z chenxiansheng
2022-05-22T06:56:21.003155944Z chenxiansheng
^C
[root@localhost ~]# 

查看容器运行进程信息

docker top 容器id

# 例子:
[root@localhost ~]# docker top 3926294a2cca
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                1967                1947                0                   14:54               ?                   00:00:00            /bin/sh -c while true;do echo chenxiansheng;sleep 1;done
root                2845                1967                0                   15:08               ?                   00:00:00            /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1

查看镜像的元数据

docker inspect  

# docker inspect 能使用的命令
[root@localhost ~]# docker inspect --help

Usage:  docker inspect [OPTIONS] NAME|ID [NAME|ID...]

Return low-level information on Docker objects

Options:
  -f, --format string   Format the output using the given Go template
  -s, --size            Display total file sizes if the type is container
      --type string     Return JSON for specified type


下面是使用例子:
# 可以看到镜像id 是该进程id的前缀
[root@localhost ~]# docker inspect 3926294a2cca
[
    {
        "Id": "3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae",
        "Created": "2022-05-22T06:54:51.055490626Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "while true;do echo chenxiansheng;sleep 1;done"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1967,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-05-22T06:54:52.152158173Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6",
        "ResolvConfPath": "/var/lib/docker/containers/3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae/hostname",
        "HostsPath": "/var/lib/docker/containers/3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae/hosts",
        "LogPath": "/var/lib/docker/containers/3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae/3926294a2cca4431540e8c5aced519f22c0999f9e6466bd96e767cea548c53ae-json.log",
        "Name": "/fervent_torvalds",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/e564fca82acaf0d594fea6217e190503e5674ff9909a45429ec75cb0d8ab2d72-init/diff:/var/lib/docker/overlay2/8da0b0258a4c475bbdf2c544b058908a98b9e203ccddd77c36dcad7dc096162a/diff",
                "MergedDir": "/var/lib/docker/overlay2/e564fca82acaf0d594fea6217e190503e5674ff9909a45429ec75cb0d8ab2d72/merged",
                "UpperDir": "/var/lib/docker/overlay2/e564fca82acaf0d594fea6217e190503e5674ff9909a45429ec75cb0d8ab2d72/diff",
                "WorkDir": "/var/lib/docker/overlay2/e564fca82acaf0d594fea6217e190503e5674ff9909a45429ec75cb0d8ab2d72/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "3926294a2cca",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "while true;do echo chenxiansheng;sleep 1;done"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20210915",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "d80dfcd35589cac557f556bf5f47895d0d7dc9eabf461985c703b240daed0f33",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/d80dfcd35589",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "41234855c20dd7890acb5e3a48217c14e61a1e3ab876d01f79ed03b88d543b88",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "5702770d4ed5c8618623571e5e7d4fa386b63c152a28bc01c40830bb8e389d21",
                    "EndpointID": "41234855c20dd7890acb5e3a48217c14e61a1e3ab876d01f79ed03b88d543b88",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

进入当前正在运行的容器

docker exec -it 容器id bashShell			# 进入容器后开启一个新的终端,可以再里面操作
docker attach 容器id						# 进入容器正在执行的终端,不会开启新的进程

-it    # 表示使用交互模式

下面是例子
[root@localhost ~]# docker exec -it 3926294a2cca /bin/bash
[root@3926294a2cca /]# 

从容器内拷贝文件到主机上

docker cp 容器id:容器内路径 目的主机路径

下面是例子: 首先进入到容器home文件夹建立一个文件,随后退出到本机,再利用docker复制命令把容器的文件复制到本机的home里面来
[root@localhost ~]# docker exec -it 3926294a2cca /bin/bash
[root@3926294a2cca /]# cd home
[root@3926294a2cca home]# 
[root@3926294a2cca home]# touch chenxiansheng222.java 
[root@3926294a2cca home]# ls
chenxiansheng222.java
[root@3926294a2cca home]# exit
exit
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                        PORTS     NAMES
3926294a2cca   centos    "/bin/sh -c 'while t…"   35 minutes ago   Up 35 minutes                           fervent_torvalds
47d1e769d463   centos    "/bin/sh -c 'while t…"   36 minutes ago   Exited (137) 35 minutes ago             great_wing
00faae8b4bf2   centos    "/bin/bash"              18 hours ago     Exited (0) 18 hours ago                 suspicious_meninsky
1581a1d0cf0a   centos    "/bin/bash"              18 hours ago     Exited (0) 18 hours ago                 serene_bouman


# 使用复制命令将容器的文件复制到本机的linux上来
[root@localhost ~]# docker cp 3926294a2cca:/home/chenxiansheng222.java /home 
[root@3926294a2cca home]# exit
exit
[root@localhost /]# cd home/
[root@localhost home]# ls
chenmaolin  chenxiansheng222.java				# 可以看到文件已经正确复制到本机上了

实际应用

docker 安装 Nginx

1、 下载nginx 镜像
2、 启动nginx
3、测试
docker run -d --name nginx01 -p 3344:80 nginx

  • -d # 设置后台运行
  • –name nginx01 # 给要启动的nginx一个名字,取名为nginx01
  • -p 3344:80 # 3344指的是linux的端口号,80指的是nginx容器的默认端口,将容器的
# 下载nginx 镜像
[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Pull complete 
a9edb18cadd1: Pull complete 
589b7251471a: Pull complete 
186b1aaa4aa6: Pull complete 
b4df32aa5a72: Pull complete 
a0bcbecc962e: Pull complete 
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    605c77e624dd   4 months ago   141MB
centos       latest    5d0da3dc9764   8 months ago   231MB

# 运行nginx镜像,参数说明:

 - -d  					# 设置后台运行
 - --name nginx01		# 给要启动的nginx一个名字,取名为nginx01	
 - -p 3344:80			# 3344指的是linux的端口号,80指的是nginx容器的默认端口,将容器的端口映射到linux端口
 - nginx 				#指的是容器名称REPOSITORY   
[root@localhost ~]# docker run -d --name nginx01 -p 3344:80 nginx
e87309bccecb4163d75b0cf6d87ebadc330e64b6de14e7c31fd0a76da19f23d8

# 查看运行的nginx ,可以看到容器运行成功
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                   NAMES
e87309bccecb   nginx     "/docker-entrypoint.…"   26 seconds ago   Up 23 seconds   0.0.0.0:3344->80/tcp, :::3344->80/tcp   nginx01

# 测试nginx,可以看到 welcome to nginx ,测试成功
[root@localhost ~]# curl localhost:3344
<!DOCTYPE html>


Welcome to nginx!<<span class="token operator">/</span>title>
<style>
html <span class="token punctuation">{</span> color-scheme: light dark<span class="token punctuation">;</span> <span class="token punctuation">}</span>
body <span class="token punctuation">{</span> width: 35em<span class="token punctuation">;</span> margin: 0 auto<span class="token punctuation">;</span>
font-family: Tahoma<span class="token punctuation">,</span> Verdana<span class="token punctuation">,</span> Arial<span class="token punctuation">,</span> sans-serif<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<<span class="token operator">/</span>style>
<<span class="token operator">/</span>head>
<body>
<h1>Welcome to nginx!<<span class="token operator">/</span>h1>
<p><span class="token keyword">If</span> you see this page<span class="token punctuation">,</span> the nginx web server is successfully installed and
working<span class="token punctuation">.</span> Further configuration is required<span class="token punctuation">.</span><<span class="token operator">/</span>p>

<p><span class="token keyword">For</span> online documentation and support please refer to
<a href=<span class="token string">"http://nginx.org/"</span>>nginx<span class="token punctuation">.</span>org<<span class="token operator">/</span>a><span class="token punctuation">.</span><br/>
Commercial support is available at
<a href=<span class="token string">"http://nginx.com/"</span>>nginx<span class="token punctuation">.</span>com<<span class="token operator">/</span>a><span class="token punctuation">.</span><<span class="token operator">/</span>p>

<p><em>Thank you <span class="token keyword">for</span> <span class="token keyword">using</span> nginx<span class="token punctuation">.</span><<span class="token operator">/</span>em><<span class="token operator">/</span>p>
<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>
</code></pre> 
  <p>还可以直接访问linux 的服务器加上上面启动的端口测试nginx是否运行成功<br> <strong>这个192.168.239.128 是我的linux服务器的地址</strong><br> <a href="http://img.e-com-net.com/image/info8/4f35c2ea05254b22b94ece511ac239b9.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/4f35c2ea05254b22b94ece511ac239b9.jpg" alt="Docker 入门流程_第2张图片" width="650" height="337" style="border:1px solid black;"></a></p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 进入到nginx容器查看</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker exec -it e87309bccecb /bin/bash</span>
root@e87309bccecb:<span class="token operator">/</span><span class="token comment"># ls</span>
bin   dev		   docker-entrypoint<span class="token punctuation">.</span>sh  home  lib64  mnt  proc  run   srv  tmp  <span class="token keyword">var</span>
boot  docker-entrypoint<span class="token punctuation">.</span>d  etc			 lib   media  opt  root  sbin  sys  usr
root@e87309bccecb:<span class="token operator">/</span><span class="token comment"># whereis nginx</span>
nginx: <span class="token operator">/</span>usr/sbin/nginx <span class="token operator">/</span>usr/lib/nginx <span class="token operator">/</span>etc/nginx <span class="token operator">/</span>usr/share/nginx
root@e87309bccecb:<span class="token operator">/</span><span class="token comment"># </span>

</code></pre> 
  <h4>docker 安装tomcat</h4> 
  <pre><code class="prism language-powershell">docker  run <span class="token operator">-</span>it  <span class="token operator">--</span><span class="token function">rm</span>  tomcat:9<span class="token punctuation">.</span>0			

 <span class="token operator">-</span> <span class="token operator">-</span><span class="token function">rm</span>  指的是运行容器停止后,在docker <span class="token function">ps</span> <span class="token operator">-</span>a 下会搜不到历史运行的该容器的id<span class="token punctuation">,</span>也就是停止容器后,会立马把该容器的历史删除掉

<span class="token comment"># 首先下载tomcat镜像</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker pull tomcat:9.0</span>
9<span class="token punctuation">.</span>0: Pulling <span class="token keyword">from</span> 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 
7662046c36cb: Pull complete 
b93639122cb4: Pull complete 
Digest: sha256:cd96d4f7d3f5fc4d3bc1622ec678207087b8215d55021a607ecaefba80b403ea
Status: Downloaded newer image <span class="token keyword">for</span> tomcat:9<span class="token punctuation">.</span>0
docker<span class="token punctuation">.</span>io/library/tomcat:9<span class="token punctuation">.</span>0

<span class="token comment"># 运行tomcat ,可以正常看到输出的tomcat的启动日志</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker run -it --rm tomcat:9.0</span>
<span class="token keyword">Using</span> CATALINA_BASE:   <span class="token operator">/</span>usr/local/tomcat
<span class="token keyword">Using</span> CATALINA_HOME:   <span class="token operator">/</span>usr/local/tomcat
<span class="token keyword">Using</span> CATALINA_TMPDIR: <span class="token operator">/</span>usr/local/tomcat/temp
<span class="token keyword">Using</span> JRE_HOME:        <span class="token operator">/</span>usr/local/openjdk-11
<span class="token keyword">Using</span> CLASSPATH:       <span class="token operator">/</span>usr/local/tomcat/bin/bootstrap<span class="token punctuation">.</span>jar:<span class="token operator">/</span>usr/local/tomcat/bin/tomcat-juli<span class="token punctuation">.</span>jar
<span class="token keyword">Using</span> CATALINA_OPTS:   
NOTE: Picked up JDK_JAVA_OPTIONS:  <span class="token operator">--</span><span class="token function">add-opens</span>=java<span class="token punctuation">.</span>base/java<span class="token punctuation">.</span>lang=ALL-UNNAMED <span class="token operator">--</span><span class="token function">add-opens</span>=java<span class="token punctuation">.</span>base/java<span class="token punctuation">.</span>io=ALL-UNNAMED <span class="token operator">--</span><span class="token function">add-opens</span>=java<span class="token punctuation">.</span>base/java<span class="token punctuation">.</span>util=ALL-UNNAMED <span class="token operator">--</span><span class="token function">add-opens</span>=java<span class="token punctuation">.</span>base/java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>concurrent=ALL-UNNAMED <span class="token operator">--</span><span class="token function">add-opens</span>=java<span class="token punctuation">.</span>rmi/sun<span class="token punctuation">.</span>rmi<span class="token punctuation">.</span>transport=ALL-UNNAMED
22-May-2022 13:44:17<span class="token punctuation">.</span>732 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Server version name:   Apache Tomcat/9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>56
22-May-2022 13:44:17<span class="token punctuation">.</span>736 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Server built:          Dec 2 2021 14:30:07 UTC
22-May-2022 13:44:17<span class="token punctuation">.</span>743 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log CATALINA_HOME:         <span class="token operator">/</span>usr/local/tomcat
22-May-2022 13:44:17<span class="token punctuation">.</span>817 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Djava<span class="token punctuation">.</span>util<span class="token punctuation">.</span>logging<span class="token punctuation">.</span>config<span class="token punctuation">.</span>file=<span class="token operator">/</span>usr/local/tomcat/conf/logging<span class="token punctuation">.</span>properties
22-May-2022 13:44:17<span class="token punctuation">.</span>818 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Djava<span class="token punctuation">.</span>util<span class="token punctuation">.</span>logging<span class="token punctuation">.</span>manager=org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>juli<span class="token punctuation">.</span>ClassLoaderLogManager
22-May-2022 13:44:17<span class="token punctuation">.</span>818 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Djdk<span class="token punctuation">.</span>tls<span class="token punctuation">.</span>ephemeralDHKeySize=2048
22-May-2022 13:44:17<span class="token punctuation">.</span>819 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Djava<span class="token punctuation">.</span>protocol<span class="token punctuation">.</span>handler<span class="token punctuation">.</span>pkgs=org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>webresources
22-May-2022 13:44:17<span class="token punctuation">.</span>819 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Dorg<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>security<span class="token punctuation">.</span>SecurityListener<span class="token punctuation">.</span>UMASK=0027
22-May-2022 13:44:17<span class="token punctuation">.</span>819 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Dignore<span class="token punctuation">.</span>endorsed<span class="token punctuation">.</span>dirs=
22-May-2022 13:44:17<span class="token punctuation">.</span>819 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Dcatalina<span class="token punctuation">.</span>base=<span class="token operator">/</span>usr/local/tomcat
22-May-2022 13:44:17<span class="token punctuation">.</span>819 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Dcatalina<span class="token punctuation">.</span>home=<span class="token operator">/</span>usr/local/tomcat
22-May-2022 13:44:17<span class="token punctuation">.</span>820 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>VersionLoggerListener<span class="token punctuation">.</span>log Command line argument: <span class="token operator">-</span>Djava<span class="token punctuation">.</span>io<span class="token punctuation">.</span>tmpdir=<span class="token operator">/</span>usr/local/tomcat/temp
22-May-2022 13:44:17<span class="token punctuation">.</span>866 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>AprLifecycleListener<span class="token punctuation">.</span>lifecycleEvent Loaded Apache Tomcat Native library <span class="token punctuation">[</span>1<span class="token punctuation">.</span>2<span class="token punctuation">.</span>31<span class="token punctuation">]</span> <span class="token keyword">using</span> APR version <span class="token punctuation">[</span>1<span class="token punctuation">.</span>7<span class="token punctuation">.</span>0<span class="token punctuation">]</span><span class="token punctuation">.</span>
22-May-2022 13:44:17<span class="token punctuation">.</span>866 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>AprLifecycleListener<span class="token punctuation">.</span>lifecycleEvent APR capabilities: IPv6 <span class="token namespace">[true]</span><span class="token punctuation">,</span> sendfile <span class="token namespace">[true]</span><span class="token punctuation">,</span> accept filters <span class="token namespace">[false]</span><span class="token punctuation">,</span> random <span class="token namespace">[true]</span><span class="token punctuation">,</span> UDS <span class="token namespace">[true]</span><span class="token punctuation">.</span>
22-May-2022 13:44:17<span class="token punctuation">.</span>866 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>AprLifecycleListener<span class="token punctuation">.</span>lifecycleEvent APR/OpenSSL configuration: useAprConnector <span class="token namespace">[false]</span><span class="token punctuation">,</span> useOpenSSL <span class="token namespace">[true]</span>
22-May-2022 13:44:17<span class="token punctuation">.</span>889 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>AprLifecycleListener<span class="token punctuation">.</span>initializeSSL OpenSSL successfully initialized <span class="token namespace">[OpenSSL 1.1.1k  25 Mar 2021]</span>
22-May-2022 13:44:19<span class="token punctuation">.</span>883 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>coyote<span class="token punctuation">.</span>AbstractProtocol<span class="token punctuation">.</span>init Initializing ProtocolHandler <span class="token punctuation">[</span><span class="token string">"http-nio-8080"</span><span class="token punctuation">]</span>
22-May-2022 13:44:20<span class="token punctuation">.</span>074 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>Catalina<span class="token punctuation">.</span>load Server initialization in <span class="token punctuation">[</span>3403<span class="token punctuation">]</span> milliseconds
22-May-2022 13:44:20<span class="token punctuation">.</span>392 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>StandardService<span class="token punctuation">.</span>startInternal Starting service <span class="token namespace">[Catalina]</span>
22-May-2022 13:44:20<span class="token punctuation">.</span>402 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>core<span class="token punctuation">.</span>StandardEngine<span class="token punctuation">.</span>startInternal Starting Servlet engine: <span class="token namespace">[Apache Tomcat/9.0.56]</span>
22-May-2022 13:44:20<span class="token punctuation">.</span>446 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>coyote<span class="token punctuation">.</span>AbstractProtocol<span class="token punctuation">.</span><span class="token function">start</span> Starting ProtocolHandler <span class="token punctuation">[</span><span class="token string">"http-nio-8080"</span><span class="token punctuation">]</span>
22-May-2022 13:44:20<span class="token punctuation">.</span>516 INFO <span class="token namespace">[main]</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>startup<span class="token punctuation">.</span>Catalina<span class="token punctuation">.</span><span class="token function">start</span> Server startup in <span class="token punctuation">[</span>441<span class="token punctuation">]</span> milliseconds


</code></pre> 
  <p>这里可以看到,tomcat容器启动完后,容器也被删除了,这就是–rm 命令的作用<br> <a href="http://img.e-com-net.com/image/info8/3b602ab72662425bb6e2652786b8b05c.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/3b602ab72662425bb6e2652786b8b05c.jpg" alt="在这里插入图片描述" width="650" height="86"></a></p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 继续测试,利用linux的地址,进行访问tomcat(将tomcat8080的默认端口映射到本机的3355端口)</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker run -d -p 3355:8080 --name tomcat01 tomcat </span>
77a49b3e9292c5e9bd7acd8bf9f85db7e07005493819fd6773f8158c02c1e670

<span class="token comment"># 测试访问linux:3355地址,会发现报404,原因是因为该tomcat是阉割版,webapps文件是空的</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># curl localhost:3355</span>
<<span class="token operator">!</span>doctype html><html lang=<span class="token string">"en"</span>><head><title>HTTP Status 404 – Not Found<<span class="token operator">/</span>title><style <span class="token function">type</span>=<span class="token string">"text/css"</span>>body <span class="token punctuation">{</span>font-family:Tahoma<span class="token punctuation">,</span>Arial<span class="token punctuation">,</span>sans-serif<span class="token punctuation">;</span><span class="token punctuation">}</span> h1<span class="token punctuation">,</span> h2<span class="token punctuation">,</span> h3<span class="token punctuation">,</span> b <span class="token punctuation">{</span>color:white<span class="token punctuation">;</span>background-color:<span class="token comment">#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>[root@localhost ~]# ^C</span>
</code></pre> 
  <p>利用linux地址:3355访问测试<a href="http://img.e-com-net.com/image/info8/8166147b00b04abeb0e2d9fc0321ac2a.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/8166147b00b04abeb0e2d9fc0321ac2a.jpg" alt="Docker 入门流程_第3张图片" width="650" height="181" style="border:1px solid black;"></a></p> 
  <p>那为什么使用linux地址:3355 没有访问tomcat成功呢,明明容器已经正常启动了。<br> 原因是因为该tomcat是阉割版本的,对应的webapps文件夹下是空的</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 进入到tomcat容器里,ls查看目录</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker exec -it 77a49b3e9292 /bin/bash</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># ls</span>
BUILDING<span class="token punctuation">.</span>txt	 LICENSE  README<span class="token punctuation">.</span>md	 RUNNING<span class="token punctuation">.</span>txt  conf  logs	    temp     webapps<span class="token punctuation">.</span>dist
CONTRIBUTING<span class="token punctuation">.</span>md  NOTICE   RELEASE-NOTES  bin	      lib   native-jni-lib  webapps  work

<span class="token comment"># 进入到webapps目录,发现是空目录</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cd webapps</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token comment"># ls</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token comment"># </span>
</code></pre> 
  <p>但是,可以看到,虽然该阉割版的tomcat的webapps目录是空的,但是对应的webapps.dist 目录却是有内容的,而里面的内容刚好是webapps文件所需要的</p> 
  <pre><code class="prism language-powershell">root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cd webapps.dist/</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token punctuation">.</span>dist<span class="token comment"># ll		# 由于是阉割版本,所有ll命令都没有</span>
bash: ll: command not found

<span class="token comment"># 可以看到,webapps.dist 目录下的文件都是webapps所需要的,把它复制到webapps 目录下</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token punctuation">.</span>dist<span class="token comment"># ls</span>
ROOT  docs  examples  host-manager  manager					
</code></pre> 
  <p>使用cp命令,将webapps.dist 目录下的文件拷贝到webapps 目录下,使用本机地址加3355端口号就可以成功访问tomcat了</p> 
  <pre><code class="prism language-powershell">root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cp -r  webapps.dist/* webapps</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cd webapps</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token comment"># ls</span>
ROOT  docs  examples  host-manager  manager				<span class="token comment"># webapps文件有内容了</span>

</code></pre> 
  <p>重新使用liunx地址+3355 (前面启动tomcat容器的时候指定了映射到linux的3355端口)端口号访问:<br> <a href="http://img.e-com-net.com/image/info8/a862c95ea4c14250a5168667e4db8f02.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/a862c95ea4c14250a5168667e4db8f02.jpg" alt="Docker 入门流程_第4张图片" width="650" height="565" style="border:1px solid black;"></a><br> 熟悉的tomcat页面,访问成功!!!</p> 
  <h2>docker图形化安装</h2> 
  <h4>安装portainer</h4> 
  <blockquote> 
   <p>portainer:Docker图形化界面管理工具! 提供一个后台面板供我们操作</p> 
  </blockquote> 
  <p>使用下面的命令安装portainer,并把端口映射到linux的8088端口(这样就可以用linux地址+端口号访问了)</p> 
  <blockquote> 
   <p>docker run -d -p 8088:9000 <br> –restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer</p> 
  </blockquote> 
  <p>安装成功<br> <a href="http://img.e-com-net.com/image/info8/09619b6379ec471797ff385ca6fce869.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/09619b6379ec471797ff385ca6fce869.jpg" alt="Docker 入门流程_第5张图片" width="650" height="539" style="border:1px solid black;"></a><br> 设置账号:root 密码:rootroot</p> 
  <p>登陆后,选择连接本地,可以查看已有的镜像(不是重点,一般不用,了解即可):<br> <a href="http://img.e-com-net.com/image/info8/8e3770e04a924bada4346d2d27b6d874.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/8e3770e04a924bada4346d2d27b6d874.jpg" alt="Docker 入门流程_第6张图片" width="650" height="334" style="border:1px solid black;"></a></p> 
  <h2>镜像的分层的含义(待补充)</h2> 
  <h4>commit镜像</h4> 
  <blockquote> 
   <p>docker commit</p> 
  </blockquote> 
  <pre><code class="prism language-powershell">提交镜像命令:docker commit <span class="token operator">-</span>a=<span class="token string">"chenxiansheng"</span> <span class="token operator">-</span>m=<span class="token string">"add webapps app"</span> 77a49b3e9292 chentomcat:1<span class="token punctuation">.</span>0
参数说明:
 <span class="token operator">-</span> <span class="token operator">-</span>a=<span class="token string">"chenxiansheng"</span>				<span class="token comment"># 提交的人的标识</span>
 <span class="token operator">-</span> <span class="token operator">-</span>m=<span class="token string">"add webapps app"</span>    			<span class="token comment">#提交的描述</span>
 <span class="token operator">-</span>  77a49b3e9292 					<span class="token comment">#容器id</span>
 <span class="token operator">-</span> chentomcat:1<span class="token punctuation">.</span>0					<span class="token comment">#设定镜像名称,并设定版本为1.0</span>

步骤:
<span class="token comment"># 1、首先利用上面下载好的tomcat镜像,启动一个tomcat容器</span>
<span class="token comment"># 2、然而这个默认的tomcat是没有webapps应用的,镜像的原因,官方的镜像默认webapps下面是没有文件的</span>
<span class="token comment"># 3、把基本文件拷贝进webapps里面</span>
<span class="token comment"># 4、将上面操作过的容器通过commit 提交为一个新的镜像,以后就可以使用自己的镜像,可以直接访问tomcat页面成功。</span>
</code></pre> 
  <blockquote> 
   <p>上面说的步骤,有不懂的,可以查看上面的docker 安装tomcat ,由于官方的tomcat是阉割版的,访问不了tomcat页面(原因是webapps目录没有文件),我们这里就把他优化一下,就是把webapps目录的文件补充完整。</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 使用cp命令,将webapps.dist 目录下的文件拷贝到webapps 目录下,使用本机地址加3355端口号就可以成功访问tomcat了</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cp -r  webapps.dist/* webapps</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat<span class="token comment"># cd webapps</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token comment"># ls</span>
ROOT  docs  examples  host-manager  manager				<span class="token comment"># webapps文件有内容了</span>
</code></pre> 
  <p>测试一下<br> <a href="http://img.e-com-net.com/image/info8/3313deb49f3a43f1a196a1150a10b193.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/3313deb49f3a43f1a196a1150a10b193.jpg" alt="Docker 入门流程_第7张图片" width="650" height="420" style="border:1px solid black;"></a><br> 测试没有问题,现在把这个运行的容器,提交成我们自己的镜像。以后运行就用我们自己的tomcat镜像,就不需要再做一次将webapps.dict 目录的文件拷贝到webapps目录下的操作后,才能查看tomcat页面了。</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 从刚刚启动的容器中退出来</span>
root@77a49b3e9292:<span class="token operator">/</span>usr/local/tomcat/webapps<span class="token comment"># exit</span>
<span class="token keyword">exit</span>

<span class="token comment"># 使用提交镜像命令</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker commit -a="chenxiansheng" -m="add webapps app" 77a49b3e9292 chentomcat:1.0</span>
sha256:8c3fc729e0f1c139d2b7b1cbe7acb2c3f12cb5c8e3cdf307dc5813fb8258c613

</code></pre> 
  <blockquote> 
   <p>可以看到我们已经生成了自己的镜像了 chentomcat</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker images</span>
REPOSITORY            TAG       IMAGE ID       CREATED              SIZE
chentomcat            1<span class="token punctuation">.</span>0       8c3fc729e0f1   About a minute ago   684MB
nginx                 latest    605c77e624dd   4 months ago         141MB
tomcat                9<span class="token punctuation">.</span>0       b8e65a4d736d   5 months ago         680MB
tomcat                latest    fb5657adc892   5 months ago         680MB
centos                latest    5d0da3dc9764   8 months ago         231MB
portainer/portainer   latest    580c0e4e98b0   14 months ago        79<span class="token punctuation">.</span>1MB
</code></pre> 
  <h2>容器数据卷</h2> 
  <h4>通过添加 -v 参数实现数据卷功能</h4> 
  <blockquote> 
   <p>为了将容器的数据进行持久化保存的操作。防止删掉容器后,容器内的数据也没有。<br> 作用:挂载宿主机的一个目录<br> 这里把容器想成一个单独的系统,或者说电脑,而你的宿主机目录是一个U盘,挂载后,你往宿主机该目录里放文件,那么通过容器里对应目录便可以访问到此文件,不需要重新生成容器就可以在“容器外部”添加和修改某些文件,如我用Mythri工具检测智能合约漏洞,采用docker容器如下命令:docker run -v $(pwd):/tmp mythril/myth analyze /tmp/test.sol,将宿主机当前目录挂载到容器的tmp目录,则在容器中操作时tmp目录就是当前的目录,在当期目录中新建智能合约或者改变旧的合约如test.sol的内容,再通过analyze命令检测合约即可,既不用重新生成容器,也不需要知道容器的绝对路径从而将新合约复制进去,只需要复制到当前目录即可。</p> 
  </blockquote> 
  <pre><code class="prism language-powershell">命令:docker run <span class="token operator">-</span>it <span class="token operator">-</span>v 主机目录:容器目录 容器名称

<span class="token comment"># 首先确认下本机linux目录下是没有其他目录的</span>
<span class="token namespace">[root@localhost /]</span><span class="token comment"># cd home/</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment">#</span>
</code></pre> 
  <blockquote> 
   <p>1、我们首先在本机的home目录下,新建一个名叫ceshi的目录,随后我们将主机的home/ceshi 目录挂载到容器的home目录下。到时候这两个目录任一一个有改动,另外一个目录也能同步改动</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 启动centos容器,并且将主机的home/ceshi目录挂载到容器的home目录,并且成功进入到容器里面</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment"># docker run -it -v /home/ceshi:/home centos</span>
<span class="token namespace">[root@9df6ac86d312 /]</span><span class="token comment"># </span>
</code></pre> 
  <blockquote> 
   <p>2、进一步查看已经开启数据卷的容器的进程信息,使用inspect命令</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># docker inspect 9df6ac86d312</span>
</code></pre> 
  <p><a href="http://img.e-com-net.com/image/info8/9542a49e702e499b9a79a337c9883fdd.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/9542a49e702e499b9a79a337c9883fdd.jpg" alt="Docker 入门流程_第8张图片" width="650" height="228" style="border:1px solid black;"></a></p> 
  <blockquote> 
   <p>3、新开一个会话,进入到linux的home/ceshi目录下,可以看到,ceshi目录是没有任何文件的</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost home]</span><span class="token comment"># cd ceshi/</span>
<span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># ls</span>
<span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># </span>
</code></pre> 
  <blockquote> 
   <p>4、开始测试,往容器的home目录添加文件,新建test.java文件</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@9df6ac86d312 /]</span><span class="token comment"># cd home/</span>
<span class="token namespace">[root@9df6ac86d312 home]</span><span class="token comment"># touch test.java</span>
<span class="token namespace">[root@9df6ac86d312 home]</span><span class="token comment"># ls</span>
test<span class="token punctuation">.</span>java
<span class="token namespace">[root@9df6ac86d312 home]</span><span class="token comment"># </span>

</code></pre> 
  <blockquote> 
   <p>5、去linux的home/ceshi目录查看,是否有新建的test.java文件</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># ls</span>
test<span class="token punctuation">.</span>java
</code></pre> 
  <p>结果:可以看到,主机目录已经成功挂载到容器的目录里。容器里面的home目录有什么变动,linux下的home/ceshi目录也会跟着同步。</p> 
  <p>下面我们来变动linux中home/ceshi/test.java文件,那容器home目录下的test.java文件会不会也会跟着变动呢?</p> 
  <blockquote> 
   <p>1、这里,我往linux的test.java文件,输入了一行字,:wq 保存退出。</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># vi test.java</span>
<span class="token namespace">[root@localhost ceshi]</span><span class="token comment"># cat test.java </span>
hello<span class="token punctuation">,</span>chenxiansheng
<span class="token namespace">[root@localhost ceshi]</span><span class="token comment">#</span>
</code></pre> 
  <blockquote> 
   <p>2、现在去查看容器的test.java文件,可以看到,也是同步成功的</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@9df6ac86d312 home]</span><span class="token comment"># cat test.java </span>
hello<span class="token punctuation">,</span>chenxiansheng
<span class="token namespace">[root@9df6ac86d312 home]</span><span class="token comment"># </span>

</code></pre> 
  <p>根据上面我们得出结论。容器数据卷功能,是通过在启动容器时,加上-v 参数,写上要挂载的目录和绑定的目录,使得这两个不在同一个层面的目录有了双向绑定的功能,数据可以实现同步(就算是容器已经停止运行,双向绑定的作用依然有效)。</p> 
  <h4>安装mysql进行数据卷的实战测试</h4> 
  <pre><code class="prism language-powershell"><span class="token comment"># 下载mysql镜像</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker pull mysql:5.7</span>
5<span class="token punctuation">.</span>7: Pulling <span class="token keyword">from</span> library/mysql
72a69066d2fe: Pull complete 
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
0ceb82207cd7: Pull complete 
37f2405cae96: Pull complete 
e2482e017e53: Pull complete 
70deed891d42: Pull complete 
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image <span class="token keyword">for</span> mysql:5<span class="token punctuation">.</span>7
docker<span class="token punctuation">.</span>io/library/mysql:5<span class="token punctuation">.</span>7
<span class="token comment"># 查看镜像</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker images</span>
REPOSITORY            TAG       IMAGE ID       CREATED         SIZE
chentomcat            1<span class="token punctuation">.</span>0       8c3fc729e0f1   47 hours ago    684MB
nginx                 latest    605c77e624dd   4 months ago    141MB
tomcat                9<span class="token punctuation">.</span>0       b8e65a4d736d   5 months ago    680MB
tomcat                latest    fb5657adc892   5 months ago    680MB
mysql                 5<span class="token punctuation">.</span>7       c20987f18b13   5 months ago    448MB
centos                latest    5d0da3dc9764   8 months ago    231MB
portainer/portainer   latest    580c0e4e98b0   14 months ago   79<span class="token punctuation">.</span>1MB

<span class="token comment"># 运行mysql容器。 </span>
参数说明:
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker run -d -p 3310:3306 -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root --name mysqlO1 mysql:5.7</span>
6a2caa469f09e9ff2417d31634fb50a4624118d1724f236ca0962a62989bb2f8
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># </span>
</code></pre> 
  <p>测试连接:<br> 这里我使用Navicat Premium工具连接测试<br> 192.168.239.128 是我的linux地址,可以看到,连接成功<br> <a href="http://img.e-com-net.com/image/info8/f973ed0797de4d5186841920508dd89c.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/f973ed0797de4d5186841920508dd89c.jpg" alt="Docker 入门流程_第9张图片" width="486" height="549" style="border:1px solid black;"></a><br> 查看linux中的home/mysql文件夹:<br> <a href="http://img.e-com-net.com/image/info8/214aff8d8e07407eaf1f8d0617498038.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/214aff8d8e07407eaf1f8d0617498038.jpg" alt="在这里插入图片描述" width="650" height="58"></a><br> 然后我们使用Navicat Premium 工具,在该mysql中新建test数据库:</p> 
  <p><a href="http://img.e-com-net.com/image/info8/d7d09d042d5c4b3696f3848c5bfe4384.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/d7d09d042d5c4b3696f3848c5bfe4384.jpg" alt="Docker 入门流程_第10张图片" width="378" height="220" style="border:1px solid black;"></a><br> 重新查看本机的home/mysql/data目录,可以看到,新增了test文件夹<br> <a href="http://img.e-com-net.com/image/info8/fb474022e2a04e9ea4eb363f21d5ae8d.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/fb474022e2a04e9ea4eb363f21d5ae8d.jpg" alt="在这里插入图片描述" width="650" height="77"></a></p> 
  <blockquote> 
   <p>以上得出结论,我们是在容器的mysql新建了数据库,我们可以在linux上找到容器新建的test数据库,这两个文件夹实现了双向绑定。假如我们把容器删除了,数据也不会丢失,实现了数据的持久化功能。</p> 
  </blockquote> 
  <h4>具名和匿名挂载</h4> 
  <h5>使用docker volume 查看数据卷的文件夹信息</h5> 
  <pre><code class="prism language-powershell">docker run <span class="token operator">-</span>d <span class="token operator">-</span>p <span class="token operator">--</span>name nginx01 <span class="token operator">-</span>v <span class="token operator">/</span>etc/nginx nginx
<span class="token operator">-</span>P  随机指定端口

<span class="token namespace">[root@localhost /]</span><span class="token comment"># docker run -d -P --name nginx02 -v /etc/nginx nginx</span>
5035f960746ba9a373fdeeec59e837f77793465055ade7e46e49d11d3e820a6d

<span class="token comment"># 使用docker volume 命令查看数据卷具体信息</span>
<span class="token namespace">[root@localhost /]</span><span class="token comment"># docker volume --help</span>

Usage:  docker volume COMMAND

Manage volumes

Commands:
  create      Create a volume
  inspect     Display detailed information on one or more volumes
  <span class="token function">ls</span>          List volumes
  prune       Remove all unused local volumes
  <span class="token function">rm</span>          Remove one or more volumes

Run <span class="token string">'docker volume COMMAND --help'</span> <span class="token keyword">for</span> more information on a command<span class="token punctuation">.</span>

<span class="token comment"># docker volume ls 命令列出该数据卷文件夹</span>
<span class="token namespace">[root@localhost /]</span><span class="token comment"># docker volume ls</span>
DRIVER    VOLUME NAME
local     5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef
local     d8bd26ce1c9d58e224d378446283b9166f53f1f3d9bb2ae3419d0dd67667cb20
</code></pre> 
  <blockquote> 
   <p>因为上面的命令匿名挂载,也就是没有指定主机目录,所以它会自己生成一个目录,这里我都进入看过,它会把5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef 目录挂载到容器的/etc/nginx目录中。<br> 下面我们继续使用docker volume 命令,查看数据卷文件夹具体路径:</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost home]</span><span class="token comment"># docker volume inspect 5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef</span>
<span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
        <span class="token string">"CreatedAt"</span>: <span class="token string">"2022-05-25T21:55:11+08:00"</span><span class="token punctuation">,</span>
        <span class="token string">"Driver"</span>: <span class="token string">"local"</span><span class="token punctuation">,</span>
        <span class="token string">"Labels"</span>: null<span class="token punctuation">,</span>
        <span class="token string">"Mountpoint"</span>: <span class="token string">"/var/lib/docker/volumes/5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef/_data"</span><span class="token punctuation">,</span>
        <span class="token string">"Name"</span>: <span class="token string">"5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef"</span><span class="token punctuation">,</span>
        <span class="token string">"Options"</span>: null<span class="token punctuation">,</span>
        <span class="token string">"Scope"</span>: <span class="token string">"local"</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
</code></pre> 
  <blockquote> 
   <p>从上面可以看出来,数据卷的文件夹放在/var/lib/docker/volumes/目录下,我们直接去到该目录下查看是否有nginx的文件</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost home]</span><span class="token comment"># cd /var/lib/docker/volumes/5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef/</span>
<span class="token namespace">[root@localhost 5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef]</span><span class="token comment"># ls</span>
_data
<span class="token namespace">[root@localhost 5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef]</span><span class="token comment"># cd _data/</span>
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># ls</span>
conf<span class="token punctuation">.</span>d  fastcgi_params  mime<span class="token punctuation">.</span>types  modules  nginx<span class="token punctuation">.</span>conf  scgi_params  uwsgi_params
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># cat nginx.conf </span>

user  nginx<span class="token punctuation">;</span>
worker_processes  auto<span class="token punctuation">;</span>

error_log  <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx/error<span class="token punctuation">.</span>log notice<span class="token punctuation">;</span>
pid        <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>run/nginx<span class="token punctuation">.</span>pid<span class="token punctuation">;</span>


events <span class="token punctuation">{</span>
    worker_connections  1024<span class="token punctuation">;</span>
<span class="token punctuation">}</span>


http <span class="token punctuation">{</span>
    include       <span class="token operator">/</span>etc/nginx/mime<span class="token punctuation">.</span>types<span class="token punctuation">;</span>
    default_type  application/octet-stream<span class="token punctuation">;</span>

    log_format  main  <span class="token string">'$remote_addr - $remote_user [$time_local] "$request" '</span>
                      <span class="token string">'$status $body_bytes_sent "$http_referer" '</span>
                      <span class="token string">'"$http_user_agent" "$http_x_forwarded_for"'</span><span class="token punctuation">;</span>

    access_log  <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx/access<span class="token punctuation">.</span>log  main<span class="token punctuation">;</span>

    sendfile        on<span class="token punctuation">;</span>
    <span class="token comment">#tcp_nopush     on;</span>

    keepalive_timeout  65<span class="token punctuation">;</span>

    <span class="token comment">#gzip  on;</span>

    include <span class="token operator">/</span>etc/nginx/conf<span class="token punctuation">.</span>d/<span class="token operator">*</span><span class="token punctuation">.</span>conf<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># </span>
</code></pre> 
  <blockquote> 
   <p>可以看到,nginx文件也是正确同步的。匿名挂载的缺点,就是生成的挂载目录的名字是不确定的,使我们不知道真正挂载的目录是哪一个,只能一个个找。</p> 
  </blockquote> 
  <h5>具名挂载</h5> 
  <p>同样,我们启动一个nginx容器,这一次我们指定主机目录juming (没有放在相对路径上,前面不需要加 “/”) ,此时再用docker volume 命令去查看目录的路径</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost /]</span><span class="token comment"># docker run -d -P --name nginx04 -v  juming:/etc/nginx nginx</span>
d68b6d085d0304d43e205c5627c1fc790aea3391b09bf7b6304b2c71cafc8376
<span class="token namespace">[root@localhost /]</span><span class="token comment"># docker volume ls</span>
DRIVER    VOLUME NAME
local     5935c0c061619752d5939c6c0567a588feacb171ec5bbe15be327e1952a32aef
local     d8bd26ce1c9d58e224d378446283b9166f53f1f3d9bb2ae3419d0dd67667cb20
local     juming

<span class="token comment"># 使用 docker volume inspect 查看挂载目录的路径</span>
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># docker volume inspect juming</span>
<span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
        <span class="token string">"CreatedAt"</span>: <span class="token string">"2022-05-25T22:29:57+08:00"</span><span class="token punctuation">,</span>
        <span class="token string">"Driver"</span>: <span class="token string">"local"</span><span class="token punctuation">,</span>
        <span class="token string">"Labels"</span>: null<span class="token punctuation">,</span>
        <span class="token string">"Mountpoint"</span>: <span class="token string">"/var/lib/docker/volumes/juming/_data"</span><span class="token punctuation">,</span>
        <span class="token string">"Name"</span>: <span class="token string">"juming"</span><span class="token punctuation">,</span>
        <span class="token string">"Options"</span>: null<span class="token punctuation">,</span>
        <span class="token string">"Scope"</span>: <span class="token string">"local"</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">]</span>


<span class="token comment"># 进入到该挂载目录的_data目录,可以看到nginx.conf  也是存在的,说明具名挂载也是成功的</span>
<span class="token namespace">[root@localhost /]</span><span class="token comment"># cd var/lib/docker/volumes/juming/_data/</span>
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># ls</span>
conf<span class="token punctuation">.</span>d  fastcgi_params  mime<span class="token punctuation">.</span>types  modules  nginx<span class="token punctuation">.</span>conf  scgi_params  uwsgi_params
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># cat nginx.conf </span>

user  nginx<span class="token punctuation">;</span>
worker_processes  auto<span class="token punctuation">;</span>

error_log  <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx/error<span class="token punctuation">.</span>log notice<span class="token punctuation">;</span>
pid        <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>run/nginx<span class="token punctuation">.</span>pid<span class="token punctuation">;</span>


events <span class="token punctuation">{</span>
    worker_connections  1024<span class="token punctuation">;</span>
<span class="token punctuation">}</span>


http <span class="token punctuation">{</span>
    include       <span class="token operator">/</span>etc/nginx/mime<span class="token punctuation">.</span>types<span class="token punctuation">;</span>
    default_type  application/octet-stream<span class="token punctuation">;</span>

    log_format  main  <span class="token string">'$remote_addr - $remote_user [$time_local] "$request" '</span>
                      <span class="token string">'$status $body_bytes_sent "$http_referer" '</span>
                      <span class="token string">'"$http_user_agent" "$http_x_forwarded_for"'</span><span class="token punctuation">;</span>

    access_log  <span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx/access<span class="token punctuation">.</span>log  main<span class="token punctuation">;</span>

    sendfile        on<span class="token punctuation">;</span>
    <span class="token comment">#tcp_nopush     on;</span>

    keepalive_timeout  65<span class="token punctuation">;</span>

    <span class="token comment">#gzip  on;</span>

    include <span class="token operator">/</span>etc/nginx/conf<span class="token punctuation">.</span>d/<span class="token operator">*</span><span class="token punctuation">.</span>conf<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token namespace">[root@localhost _data]</span><span class="token comment"># </span>

</code></pre> 
  <blockquote> 
   <p>从上面的匿名挂载和具名挂载得出结论,<br> 不同点: 匿名挂载就是挂载的时候不主动指定要挂载的主机目录,此时会自动生成一个挂载目录,但是具体叫什么名字我们不清楚,只能使用 ”docker inspect 容器id “命令,从进程信息的mounts找出挂载的本机目录名称。 具名挂载就是在挂载的时候手动指定一个要挂载的目录,此时我们 ”docker volume ls “命令就能很轻松找到对应的主机目录。<br> 相同点:具名挂载和匿名挂载的主机目录都是存放在"/var/lib/docker/volumes/"路径上的</p> 
  </blockquote> 
  <p>拓展:</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 通过 -v 容器内路径:ro  /rw 改变读写权限</span>
ro:				<span class="token comment"># 只读</span>
rw:				<span class="token comment"># 可读可写</span>
 docker run <span class="token operator">-</span>d <span class="token operator">-</span>P <span class="token operator">--</span>name nginx03 <span class="token operator">-</span>v  <span class="token operator">/</span>home/juming:<span class="token operator">/</span>etc/nginx:ro nginx
 docker run <span class="token operator">-</span>d <span class="token operator">-</span>P <span class="token operator">--</span>name nginx03 <span class="token operator">-</span>v  <span class="token operator">/</span>home/juming:<span class="token operator">/</span>etc/nginx:rw nginx
</code></pre> 
  <blockquote> 
   <p>#ro 只要看到ro 就说明这个路径只能通过宿主机来操作,容器内部无法操作!(测试:看下面两张图片)</p> 
  </blockquote> 
  <p>往主机添加test.java文件(图1),可以看到容器也有test.java文件(图2),但是往容器添加test2.java文件,却报只有只读权限(图2)。<br> 图1<br> <a href="http://img.e-com-net.com/image/info8/9a25e4d0a6994644bad1819724574b32.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/9a25e4d0a6994644bad1819724574b32.jpg" alt="Docker 入门流程_第11张图片" width="650" height="304" style="border:1px solid black;"></a></p> 
  <p>图2 <br> <a href="http://img.e-com-net.com/image/info8/fd349ea373f845c6b7c486ca7a1a1416.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/fd349ea373f845c6b7c486ca7a1a1416.jpg" alt="Docker 入门流程_第12张图片" width="650" height="111" style="border:1px solid black;"></a></p> 
  <h4>初识Dockerfile</h4> 
  <h5>构建dockerfile命令:docker build</h5> 
  <blockquote> 
   <p>Dockerfile 就是用来构建 docker 镜像的构建文件,命令脚本!<br> 通过这个脚本可以生成镜像,镜像是一层一层的,脚本一个个的命令。每一个命令都是一层。</p> 
  </blockquote> 
  <p>构建自己的镜像</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个dockerfile文件,名字可以随机,建议叫:dockerfile</span>
<span class="token comment"># 文件中的内容 指令(大写)	参数</span>

<span class="token comment"># 第一步,在本机的home目录新建一个docker-test-volume 目录</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment"># mkdir docker-test-volume</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment"># ls</span>
ceshi  chenmaolin  chenxiansheng222<span class="token punctuation">.</span>java  docker-<span class="token function">test-volume</span>  juming  mysql

<span class="token comment"># 第二部,进入到该目录,新建一个名为dockerfile1的文件,并写上内容</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment"># cd docker-test-volume/</span>
<span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># vi dockerfile1</span>
<span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># cat dockerfile1</span>
<span class="token keyword">FROM</span> centos

VOLUME <span class="token punctuation">[</span><span class="token string">"volume01"</span><span class="token punctuation">,</span><span class="token string">"volume02"</span><span class="token punctuation">]</span>

CMD <span class="token function">echo</span> <span class="token string">"-------end------"</span>
CMD <span class="token operator">/</span>bin/bash

<span class="token comment"># 第三步,使用构建镜像的命,docker build</span>
<span class="token operator">-</span>f 		<span class="token comment"># 指定要构建的文件</span>
<span class="token operator">-</span>t 		<span class="token comment"># 要生成的镜像</span>
<span class="token punctuation">.</span>		<span class="token comment"># 表示当前目录</span>
<span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># docker build -f /home/docker-test-volume/dockerfile1 -t chenxiansheng/centos:1.0 .</span>
Sending build context to Docker daemon  2<span class="token punctuation">.</span>048kB
Step 1/4 : <span class="token keyword">FROM</span> centos
 <span class="token operator">--</span><span class="token operator">-</span>> 5d0da3dc9764
Step 2/4 : VOLUME <span class="token punctuation">[</span><span class="token string">"volume01"</span><span class="token punctuation">,</span><span class="token string">"volume02"</span><span class="token punctuation">]</span>
 <span class="token operator">--</span><span class="token operator">-</span>> Running in de2d516d27b4
Removing intermediate container de2d516d27b4
 <span class="token operator">--</span><span class="token operator">-</span>> ab91177ccd23
Step 3/4 : CMD <span class="token function">echo</span> <span class="token string">"-------end------"</span>
 <span class="token operator">--</span><span class="token operator">-</span>> Running in da532b3a90af
Removing intermediate container da532b3a90af
 <span class="token operator">--</span><span class="token operator">-</span>> 3dfd8b7d5bde
Step 4/4 : CMD <span class="token operator">/</span>bin/bash
 <span class="token operator">--</span><span class="token operator">-</span>> Running in df8f5c472181
Removing intermediate container df8f5c472181
 <span class="token operator">--</span><span class="token operator">-</span>> b0b6b03694f5
Successfully built b0b6b03694f5
Successfully tagged chenxiansheng/centos:1<span class="token punctuation">.</span>0

<span class="token comment"># 第四步,查看镜像,可以看到自己的镜像构建成功,chenxiansheng/centos</span>
<span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># docker images</span>
REPOSITORY             TAG       IMAGE ID       CREATED         SIZE
chenxiansheng/centos   1<span class="token punctuation">.</span>0       b0b6b03694f5   8 seconds ago   231MB
chentomcat             1<span class="token punctuation">.</span>0       8c3fc729e0f1   3 days ago      684MB
nginx                  latest    605c77e624dd   4 months ago    141MB
tomcat                 9<span class="token punctuation">.</span>0       b8e65a4d736d   5 months ago    680MB
tomcat                 latest    fb5657adc892   5 months ago    680MB
mysql                  5<span class="token punctuation">.</span>7       c20987f18b13   5 months ago    448MB
centos                 latest    5d0da3dc9764   8 months ago    231MB
portainer/portainer    latest    580c0e4e98b0   14 months ago   79<span class="token punctuation">.</span>1MB
</code></pre> 
  <blockquote> 
   <p>可以看到,这里构建镜像分成了四步,并且我们前面写的输出的一句话,也正常输出来了<br> -----end------<br> <a href="http://img.e-com-net.com/image/info8/f22d25119aa84e689be68a8ea5db39ea.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/f22d25119aa84e689be68a8ea5db39ea.jpg" alt="Docker 入门流程_第13张图片" width="650" height="256" style="border:1px solid black;"></a></p> 
  </blockquote> 
  <blockquote> 
   <p>启动自己镜像进行测试</p> 
  </blockquote> 
  <p><a href="http://img.e-com-net.com/image/info8/a3f9cc2729054abe993cbad9a7ca22a5.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/a3f9cc2729054abe993cbad9a7ca22a5.jpg" alt="Docker 入门流程_第14张图片" width="650" height="286" style="border:1px solid black;"></a></p> 
  <blockquote> 
   <p>但是上面的挂载有一个问题,那就我们并没有指定本机的目录,只是挂载的容器里的目录 volume01 和volume02 ,这是属于匿名挂载。所以它生成的本机目录是一窜很长的16进制表示的目录名。</p> 
  </blockquote> 
  <p>使用docker inspect 容器id 命令,查看该容器的进程信息,就可以得到该容器的进程信息,可以从进程信息找到该容器的挂载的本机目录</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost /]</span><span class="token comment"># docker inspect d0ea1e9cf82e</span>
</code></pre> 
  <p>从进程信息中,找到mounts ,可以看到主机的目录<br> <a href="http://img.e-com-net.com/image/info8/9da96f5dfc5545b4958b1fcd2e8aa573.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/9da96f5dfc5545b4958b1fcd2e8aa573.jpg" alt="Docker 入门流程_第15张图片" width="650" height="290" style="border:1px solid black;"></a><br> 跟前面的数据卷一样,文件也是双向绑定的。在容器里的volume01目录有变动,本机的/var/lib/docker/volumes/656e215f074529196d4b1b8df2e9339286b81bba49beebeb03ea2c483d25e902/_data 也会跟着同步。同理,volume02 也一样。</p> 
  <blockquote> 
   <p>以上这种构建dockerfile的方式未来我们用的十分多。因为偶们通常会构建自己的镜像!</p> 
  </blockquote> 
  <h4>数据卷容器</h4> 
  <p>就是多个容器间进行数据共享,使用–volumes-from 命令</p> 
  <p>第一步,启动一个docker01容器,就用我们前面自己构建的镜像</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># docker run -it --name docker01 chenxiansheng/centos:1.0</span>
<span class="token namespace">[root@cf7f334a2601 /]</span><span class="token comment"># ls -l</span>
total 0
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 bin <span class="token operator">-</span>> usr/bin
drwxr-xr-x<span class="token punctuation">.</span>   5 root root 360 May 26 15:04 dev
drwxr-xr-x<span class="token punctuation">.</span>   1 root root  66 May 26 15:04 etc
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 home
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 lib <span class="token operator">-</span>> usr/lib
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   9 Nov  3  2020 lib64 <span class="token operator">-</span>> usr/lib64
drwx-<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">.</span>   2 root root   6 Sep 15  2021 lost+found
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 media
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 mnt
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 opt
dr-xr-xr-x<span class="token punctuation">.</span> 126 root root   0 May 26 15:04 proc
dr-xr-x-<span class="token operator">--</span><span class="token punctuation">.</span>   2 root root 162 Sep 15  2021 root
drwxr-xr-x<span class="token punctuation">.</span>  11 root root 163 Sep 15  2021 run
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   8 Nov  3  2020 sbin <span class="token operator">-</span>> usr/sbin
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 srv
dr-xr-xr-x<span class="token punctuation">.</span>  13 root root   0 May 26 11:41 sys
drwxrwxrwt<span class="token punctuation">.</span>   7 root root 171 Sep 15  2021 tmp
drwxr-xr-x<span class="token punctuation">.</span>  12 root root 144 Sep 15  2021 usr
drwxr-xr-x<span class="token punctuation">.</span>  20 root root 262 Sep 15  2021 <span class="token keyword">var</span>
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 May 26 15:04 volume01
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 May 26 15:04 volume02

<span class="token comment"># 随后使用ctrl+P+Q ,后台运行并退出</span>
<span class="token namespace">[root@cf7f334a2601 /]</span><span class="token comment"># [root@localhost docker-test-volume]#</span>
</code></pre> 
  <p>第二步,继承docker01镜像,启动一个docker02容器,使用–volumes-from 参数</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost docker-test-volume]</span><span class="token comment"># docker run -it --name docker02 --volumes-from docker01 chenxiansheng/centos:1.0</span>
<span class="token namespace">[root@f0cc63e30a17 /]</span><span class="token comment"># ls -l</span>
total 0
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 bin <span class="token operator">-</span>> usr/bin
drwxr-xr-x<span class="token punctuation">.</span>   5 root root 360 May 26 15:07 dev
drwxr-xr-x<span class="token punctuation">.</span>   1 root root  66 May 26 15:07 etc
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 home
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 lib <span class="token operator">-</span>> usr/lib
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   9 Nov  3  2020 lib64 <span class="token operator">-</span>> usr/lib64
drwx-<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">.</span>   2 root root   6 Sep 15  2021 lost+found
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 media
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 mnt
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 opt
dr-xr-xr-x<span class="token punctuation">.</span> 125 root root   0 May 26 15:07 proc
dr-xr-x-<span class="token operator">--</span><span class="token punctuation">.</span>   2 root root 162 Sep 15  2021 root
drwxr-xr-x<span class="token punctuation">.</span>  11 root root 163 Sep 15  2021 run
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   8 Nov  3  2020 sbin <span class="token operator">-</span>> usr/sbin
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 srv
dr-xr-xr-x<span class="token punctuation">.</span>  13 root root   0 May 26 11:41 sys
drwxrwxrwt<span class="token punctuation">.</span>   7 root root 171 Sep 15  2021 tmp
drwxr-xr-x<span class="token punctuation">.</span>  12 root root 144 Sep 15  2021 usr
drwxr-xr-x<span class="token punctuation">.</span>  20 root root 262 Sep 15  2021 <span class="token keyword">var</span>
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 May 26 15:04 volume01
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 May 26 15:04 volume02

</code></pre> 
  <p>可以看到,docker01 和docker02 都拥有volume01 和volume02 目录, 这个两个目录是同步数据的,下面我们来测试一下:</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 我们在docker01 容器的volume01 目录新建一个 test.java </span>
<span class="token namespace">[root@cf7f334a2601 /]</span><span class="token comment"># cd volume01/</span>
<span class="token namespace">[root@cf7f334a2601 volume01]</span><span class="token comment"># ls</span>
<span class="token namespace">[root@cf7f334a2601 volume01]</span><span class="token comment"># touch test.java</span>
<span class="token namespace">[root@cf7f334a2601 volume01]</span><span class="token comment"># ls</span>
test<span class="token punctuation">.</span>java
<span class="token namespace">[root@cf7f334a2601 volume01]</span><span class="token comment"># </span>
</code></pre> 
  <p>此时去到docker02 容器,查看volume01 文件,test.java文化也是存在的,这就实现了数据卷容器的同步功能</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@f0cc63e30a17 /]</span><span class="token comment"># cd volume01</span>
<span class="token namespace">[root@f0cc63e30a17 volume01]</span><span class="token comment"># ls</span>
test<span class="token punctuation">.</span>java
<span class="token namespace">[root@f0cc63e30a17 volume01]</span><span class="token comment"># </span>

</code></pre> 
  <p>那么,如果我要同步容器3、容器4 呢,这里继续测试,我们继承docker02 ,启动docker03</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost ~]</span><span class="token comment"># docker run -it --name docker03 --volumes-from docker02 chenxiansheng/centos:1.0</span>
<span class="token namespace">[root@97396699c735 /]</span><span class="token comment"># ls -l</span>
total 0
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 bin <span class="token operator">-</span>> usr/bin
drwxr-xr-x<span class="token punctuation">.</span>   5 root root 360 May 26 15:18 dev
drwxr-xr-x<span class="token punctuation">.</span>   1 root root  66 May 26 15:17 etc
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 home
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 lib <span class="token operator">-</span>> usr/lib
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   9 Nov  3  2020 lib64 <span class="token operator">-</span>> usr/lib64
drwx-<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">.</span>   2 root root   6 Sep 15  2021 lost+found
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 media
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 mnt
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 opt
dr-xr-xr-x<span class="token punctuation">.</span> 130 root root   0 May 26 15:17 proc
dr-xr-x-<span class="token operator">--</span><span class="token punctuation">.</span>   2 root root 162 Sep 15  2021 root
drwxr-xr-x<span class="token punctuation">.</span>  11 root root 163 Sep 15  2021 run
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   8 Nov  3  2020 sbin <span class="token operator">-</span>> usr/sbin
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 srv
dr-xr-xr-x<span class="token punctuation">.</span>  13 root root   0 May 26 11:41 sys
drwxrwxrwt<span class="token punctuation">.</span>   7 root root 171 Sep 15  2021 tmp
drwxr-xr-x<span class="token punctuation">.</span>  12 root root 144 Sep 15  2021 usr
drwxr-xr-x<span class="token punctuation">.</span>  20 root root 262 Sep 15  2021 <span class="token keyword">var</span>
drwxr-xr-x<span class="token punctuation">.</span>   2 root root  23 May 26 15:11 volume01
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 May 26 15:04 volume02
<span class="token namespace">[root@97396699c735 /]</span><span class="token comment"># cd volume01</span>
<span class="token namespace">[root@97396699c735 volume01]</span><span class="token comment"># ls</span>
test<span class="token punctuation">.</span>java
<span class="token namespace">[root@97396699c735 volume01]</span><span class="token comment"># </span>

</code></pre> 
  <p>可以看到,同步依然是有效的。<br> 如果docker03 继承docker01 启动,可不可以呢? 答案也是肯定的,也是能实现数据共享的!!<br> 删除了docker 01 后,docker02 和docker03 依然可以实现数据共享。跟容器是否启动是无关的!<br> 所以得出结论,要实现容器间的数据共享,只需要在docker run 增加–volumes-from 参数 父类容器名称 ,就可以实现容器间的数据共享。 只要有共同一个父类就可以。</p> 
  <blockquote> 
   <p>结论:容器之间配置信息的传递,数据卷容器的生命周期一直持续到没有容器使用为止<br> 但是一旦持久化到了本地,这个时候,本地的数据就不会删除,就算容器没有再使用了。</p> 
  </blockquote> 
  <h2>DockerFile</h2> 
  <h5>dockerfIle 是用来构建docker镜像的文件!</h5> 
  <p>构建步骤:</p> 
  <ol> 
   <li>编写一个dockerfile文件</li> 
   <li>docker build 构建成为一个镜像</li> 
   <li>docker run 运行镜像</li> 
   <li>docker push 发布镜像(DockerHub 、阿里云镜像仓库等)</li> 
  </ol> 
  <p>很多官方的镜像都是基础包,很多功能没有,我们通常会自己搭建自己的镜像。</p> 
  <h2>DockerFile 构建过程</h2> 
  <h5>基础知识:</h5> 
  <ol> 
   <li>每个保留关键字(指令) 都是必须大写字母</li> 
   <li>执行从上到下顺序执行</li> 
   <li>#表示注释</li> 
   <li>每个指令都会创建提交一个新的镜像层,并提交!<br> 类似我们上面写的,dockerfile ,就是一层一层的<br> <a href="http://img.e-com-net.com/image/info8/c15b533a06c74e9a98a9f8be63ad3754.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/c15b533a06c74e9a98a9f8be63ad3754.jpg" alt="Docker 入门流程_第16张图片" width="605" height="230" style="border:1px solid black;"></a><a href="http://img.e-com-net.com/image/info8/dd26820634a045c1be6a518999462d3f.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/dd26820634a045c1be6a518999462d3f.jpg" alt="Docker 入门流程_第17张图片" width="650" height="425" style="border:1px solid black;"></a><br> dockerfile 是面向开发的,我们以后发布项目,做镜像,就需要编写dockerfile 文件,这个文件十分简单!<br> Docker 镜像逐渐成为企业交付的标准。<br> 步骤: 开发,部署,运维<br> Dockerfile: 构建文件,定义了一切的步骤,源代码。<br> DockerImages: 通过Dockerfile 构建生成的镜像,最终发布和运行的产品!<br> Docker容器:容器就是镜像运行起来提供服务器</li> 
  </ol> 
  <h2>Dockerfile的指令</h2> 
  <p>以下是各种命令的含义:<br> <a href="http://img.e-com-net.com/image/info8/f6a710a2931d45a59286e3c6478a069e.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/f6a710a2931d45a59286e3c6478a069e.jpg" alt="Docker 入门流程_第18张图片" width="650" height="382" style="border:1px solid black;"></a></p> 
  <pre><code class="prism language-powershell">CMD 		<span class="token comment"># 指定这个容器启动的时候要运行的命令,只有最后一个会生效,可被替代</span>
ENTRYPOINT	<span class="token comment"># 指定这个容器启动的时候要运行的命令,可以追加命令</span>
ONBUILD		<span class="token comment"># 当构建一个被继承DockerFile 这个时候就会运行ONBUILD 的指令,触发指令</span>
<span class="token function">COPY</span>		<span class="token comment"># 类似ADD,将我们文件拷贝到镜像中</span>
ENY			<span class="token comment"># 构建的时候设置环境变量!</span>
</code></pre> 
  <h4>实战测试</h4> 
  <p>Docker Hub 中99% 镜像都是从这个基础镜像过来的FROM scratch ,然后配置需要的软件和配置要进行的构建</p> 
  <p>我们先启动centos ,在容器里面使用 vim 命令和 ifconfig 命令,发现,都是不支持这个命令的,说明官方的centos容器是阉割版的,那我们就自己构建一个centos,是它能够支持vim 和ifconfig命令<br> <a href="http://img.e-com-net.com/image/info8/eb336eb2ef4e470e95cb9bc7670c4976.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/eb336eb2ef4e470e95cb9bc7670c4976.jpg" alt="Docker 入门流程_第19张图片" width="535" height="136" style="border:1px solid black;"></a></p> 
  <h5>构建自己的centos</h5> 
  <p>创建目录,并在该目录新建一个mydockerfilecentos 文件,并且写上要构建的镜像指令</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost home]</span><span class="token comment"># mkdir firstdockerfile</span>
<span class="token namespace">[root@localhost home]</span><span class="token comment"># ls</span>
ceshi  chenmaolin  chenxiansheng222<span class="token punctuation">.</span>java  docker-<span class="token function">test-volume</span>  firstdockerfile  juming  mysql
<span class="token namespace">[root@localhost home]</span><span class="token comment"># cd firstdockerfile/</span>

<span class="token comment"># 1 编写Dockerfile 文件</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># vi mydockerfilecentos</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># cat mydockerfilecentos </span>
<span class="token keyword">FROM</span> centos:7										<span class="token comment"># 指定了centos 为基础镜像,因为本机的centos版本就是7.9,所以这里也要下7,都则会下载不了</span>
MAINTAINER chenxiansheng<1050480930@qq<span class="token punctuation">.</span>com>		<span class="token comment"># 维护者西你想</span>

ENV MYPATH <span class="token operator">/</span>usr/local							<span class="token comment"># 设置环境变量</span>
WORKDIR <span class="token variable">$MYPATH</span>									<span class="token comment"># 设置当前工作目录</span>

RUN  yum <span class="token operator">-</span>y install vim 						<span class="token comment"># 默认下载vim指令</span>
RUN  yum <span class="token operator">-</span>y insatll net-tools					<span class="token comment"># 默认下载网络工具包</span>

EXPOSE 80										<span class="token comment"># 指定对外的端口</span>

CMD <span class="token function">echo</span> <span class="token variable">$MYPATH</span>								<span class="token comment"># 容器启动时,要运行的命令,将工作目录打印出来</span>
CMD <span class="token function">echo</span> <span class="token string">"----end------"</span>						<span class="token comment"># 容器启动时,要运行的命令</span>
CMD <span class="token operator">/</span>bin/bash 									<span class="token comment"># 容器启动时,要启动的命令行</span>

<span class="token comment"># 2、通过这个文件构建镜像</span>
<span class="token comment"># 命令	docker build -f dockerfile文件路径</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker build -f mydockerfilecentos -t mycentos:0.1 .</span>
</code></pre> 
  <p>构建成功<br> <a href="http://img.e-com-net.com/image/info8/1240a764d6a34a5095d8d7b770958452.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/1240a764d6a34a5095d8d7b770958452.jpg" alt="Docker 入门流程_第20张图片" width="575" height="755" style="border:1px solid black;"></a></p> 
  <blockquote> 
   <p>注意查看docker容器里面的centos版本是不是8.0,本机的centos是7.9的情况,这种时候构建遇到 yum命令时会报错,需要在dockerfile文件中,指定下载为7版本的centos,即可解决</p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 3、 测试运行</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker run -it mycentos:0.1</span>

<span class="token comment"># 这里可以看到,容器默认就是进入到/usr/local,这就是我们前面设置的工作目录</span>
<span class="token namespace">[root@547054def8e6 local]</span><span class="token comment"># pwd</span>
<span class="token operator">/</span>usr/local

<span class="token comment"># 可以看到我们构建的镜像,可以使用ifconifg、vim命令了</span>
<span class="token namespace">[root@547054def8e6 local]</span><span class="token comment"># ifconfig  </span>
eth0: flags=4163<UP<span class="token punctuation">,</span>BROADCAST<span class="token punctuation">,</span>RUNNING<span class="token punctuation">,</span>MULTICAST>  mtu 1500
        inet 172<span class="token punctuation">.</span>17<span class="token punctuation">.</span>0<span class="token punctuation">.</span>4  netmask 255<span class="token punctuation">.</span>255<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0  broadcast 172<span class="token punctuation">.</span>17<span class="token punctuation">.</span>255<span class="token punctuation">.</span>255
        ether 02:42:<span class="token function">ac</span>:11:00:04  txqueuelen 0  <span class="token punctuation">(</span>Ethernet<span class="token punctuation">)</span>
        RX packets 8  bytes 656 <span class="token punctuation">(</span>656<span class="token punctuation">.</span>0 B<span class="token punctuation">)</span>
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 <span class="token punctuation">(</span>0<span class="token punctuation">.</span>0 B<span class="token punctuation">)</span>
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP<span class="token punctuation">,</span>LOOPBACK<span class="token punctuation">,</span>RUNNING>  mtu 65536
        inet 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1  netmask 255<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0
        loop  txqueuelen 1000  <span class="token punctuation">(</span>Local Loopback<span class="token punctuation">)</span>
        RX packets 0  bytes 0 <span class="token punctuation">(</span>0<span class="token punctuation">.</span>0 B<span class="token punctuation">)</span>
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 <span class="token punctuation">(</span>0<span class="token punctuation">.</span>0 B<span class="token punctuation">)</span>
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

<span class="token namespace">[root@547054def8e6 local]</span><span class="token comment">#vim  </span>
<span class="token namespace">[root@547054def8e6 local]</span><span class="token comment">#   </span>

</code></pre> 
  <h6>使用docker history 镜像id 来查看dockerfile变更历史</h6> 
  <p>我们平时拿到一个镜像,可以研究一下它是怎么做的</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker images</span>
REPOSITORY             TAG       IMAGE ID       CREATED          SIZE
mycentos               0<span class="token punctuation">.</span>1       c80a46b4bab7   12 minutes ago   601MB

<span class="token comment"># 使用镜像id查看变更历史(也就是可以查看这些镜像的dockerfile是怎么写的)</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker history c80a46b4bab7</span>
IMAGE          CREATED          CREATED BY                                      SIZE      COMMENT
c80a46b4bab7   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  CMD ["/bin/sh" "-c" "/bin…   0B        </span>
522954b80b85   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  CMD ["/bin/sh" "-c" "echo…   0B        </span>
dfcfc1df60c5   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  CMD ["/bin/sh" "-c" "echo…   0B        </span>
a04211a9bee4   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  EXPOSE 80                    0B        </span>
536afb4c9003   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c yum <span class="token operator">-</span>y install net-tools             171MB     
497262217236   13 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c yum <span class="token operator">-</span>y install vim                   226MB     
f4d69a0c750d   20 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop) WORKDIR /usr/local            0B        </span>
098b9103d5fb   20 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  ENV MYPATH=/usr/local        0B        </span>
722b4df5b913   20 minutes ago   <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  MAINTAINER chenxiansheng<…   0B        </span>
eeb6ee3f44bd   8 months ago     <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  CMD ["/bin/bash"]            0B        </span>
<missing>      8 months ago     <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop)  LABEL org.label-schema.sc…   0B        </span>
<missing>      8 months ago     <span class="token operator">/</span>bin/sh <span class="token operator">-</span>c <span class="token comment">#(nop) ADD file:b3ebbe8bd304723d4…   204MB     </span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># </span>

</code></pre> 
  <blockquote> 
   <p>CMD 和 ENTRYPOINT 区别</p> 
  </blockquote> 
  <pre><code class="prism language-powershell">CMD 			<span class="token comment"># 指定这个容器启动的时候要运行的命令,只有最后一个会生效,可被替代</span>
ENTRYPOINT		<span class="token comment"># 指定这个容器启动的时候要运行的命令,可以追加命令</span>
</code></pre> 
  <p>测试cmd</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 构建dockerfile镜像</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># vi dockerfile-cmd-test</span>

<span class="token comment"># 这里的镜像就只运行 ls -a 命令</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># cat dockerfile-cmd-test </span>
<span class="token keyword">FROM</span> centos
CMD <span class="token punctuation">[</span><span class="token string">"ls"</span><span class="token punctuation">,</span><span class="token string">"-a"</span><span class="token punctuation">]</span>

<span class="token comment"># 构建cmd镜像</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker build -f dockerfile-cmd-test -t cmdtest .</span>
Sending build context to Docker daemon  3<span class="token punctuation">.</span>072kB
Step 1/2 : <span class="token keyword">FROM</span> centos
 <span class="token operator">--</span><span class="token operator">-</span>> 5d0da3dc9764
Step 2/2 : CMD <span class="token punctuation">[</span><span class="token string">"ls"</span><span class="token punctuation">,</span><span class="token string">"-a"</span><span class="token punctuation">]</span>
 <span class="token operator">--</span><span class="token operator">-</span>> Running in 82f7e399a1f0
Removing intermediate container 82f7e399a1f0
 <span class="token operator">--</span><span class="token operator">-</span>> 0b2e5b872f1c
Successfully built 0b2e5b872f1c
Successfully tagged cmdtest:latest

<span class="token comment"># 运行cmd镜像</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker run 0b2e5b872f1c</span>
<span class="token punctuation">.</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">.</span>dockerenv
bin
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
<span class="token keyword">var</span>

<span class="token comment"># 上面可以看到,正确执行了 ls -a 命令,下面我们想要追加一个命令,变成 ls -l </span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker run 0b2e5b872f1c -l</span>
docker: Error response <span class="token keyword">from</span> daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to <span class="token function">start</span> container <span class="token keyword">process</span>: exec: <span class="token string">"-l"</span>: executable file not found in <span class="token variable">$PATH</span>: unknown<span class="token punctuation">.</span>

<span class="token comment"># cmd 的清理下,会用-l 替换 ["ls","-a"] 命令, 因为-l 不是命令,所以报错了</span>
</code></pre> 
  <p>测试ENTRYPOINT</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 构建dockerfile镜像</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># vi docker-entrypoint-test</span>

<span class="token comment"># 这里和上面一样,该镜像只执行ls -a 命令</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># cat docker-entrypoint-test </span>
<span class="token keyword">FROM</span> centos
ENTRYPOINT <span class="token punctuation">[</span><span class="token string">"ls"</span><span class="token punctuation">,</span><span class="token string">"-a"</span><span class="token punctuation">]</span>

<span class="token comment"># 构建entrypoint 镜像</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker build -f docker-entrypoint-test -t entrypointtest .</span>
Sending build context to Docker daemon  4<span class="token punctuation">.</span>096kB
Step 1/2 : <span class="token keyword">FROM</span> centos
 <span class="token operator">--</span><span class="token operator">-</span>> 5d0da3dc9764
Step 2/2 : ENTRYPOINT <span class="token punctuation">[</span><span class="token string">"ls"</span><span class="token punctuation">,</span><span class="token string">"-a"</span><span class="token punctuation">]</span>
 <span class="token operator">--</span><span class="token operator">-</span>> Running in 221b27881ee1
Removing intermediate container 221b27881ee1
 <span class="token operator">--</span><span class="token operator">-</span>> 3cdb2e38bcd8
Successfully built 3cdb2e38bcd8
Successfully tagged entrypointtest:latest

<span class="token comment"># 运行entrypoint 镜像,可以发现,运行成功</span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker run 3cdb2e38bcd8</span>
<span class="token punctuation">.</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">.</span>dockerenv
bin
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
<span class="token keyword">var</span>

<span class="token comment"># 继续追加命令,直接在后面加 -l </span>
<span class="token namespace">[root@localhost firstdockerfile]</span><span class="token comment"># docker run 3cdb2e38bcd8 -l</span>
total 0
drwxr-xr-x<span class="token punctuation">.</span>   1 root root   6 May 30 14:45 <span class="token punctuation">.</span>
drwxr-xr-x<span class="token punctuation">.</span>   1 root root   6 May 30 14:45 <span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token operator">-</span>rwxr-xr-x<span class="token punctuation">.</span>   1 root root   0 May 30 14:45 <span class="token punctuation">.</span>dockerenv
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 bin <span class="token operator">-</span>> usr/bin
drwxr-xr-x<span class="token punctuation">.</span>   5 root root 340 May 30 14:45 dev
drwxr-xr-x<span class="token punctuation">.</span>   1 root root  66 May 30 14:45 etc
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 home
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   7 Nov  3  2020 lib <span class="token operator">-</span>> usr/lib
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   9 Nov  3  2020 lib64 <span class="token operator">-</span>> usr/lib64
drwx-<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">.</span>   2 root root   6 Sep 15  2021 lost+found
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 media
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 mnt
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 opt
dr-xr-xr-x<span class="token punctuation">.</span> 135 root root   0 May 30 14:45 proc
dr-xr-x-<span class="token operator">--</span><span class="token punctuation">.</span>   2 root root 162 Sep 15  2021 root
drwxr-xr-x<span class="token punctuation">.</span>  11 root root 163 Sep 15  2021 run
lrwxrwxrwx<span class="token punctuation">.</span>   1 root root   8 Nov  3  2020 sbin <span class="token operator">-</span>> usr/sbin
drwxr-xr-x<span class="token punctuation">.</span>   2 root root   6 Nov  3  2020 srv
dr-xr-xr-x<span class="token punctuation">.</span>  13 root root   0 May 30 11:07 sys
drwxrwxrwt<span class="token punctuation">.</span>   7 root root 171 Sep 15  2021 tmp
drwxr-xr-x<span class="token punctuation">.</span>  12 root root 144 Sep 15  2021 usr
drwxr-xr-x<span class="token punctuation">.</span>  20 root root 262 Sep 15  2021 <span class="token keyword">var</span>

<span class="token comment"># 结果:-l 命令执行成功了,是因为 他只是替换了-a ,变成了 ls -l 了。所以成功运行</span>
</code></pre> 
  <h2>实战:Tomcat 镜像</h2> 
  <p>1、准备镜像文件,tomcat压缩包,jdk压缩包<br> <a href="http://img.e-com-net.com/image/info8/35ec0d91e279471983e3dc279ed6f9b1.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/35ec0d91e279471983e3dc279ed6f9b1.jpg" alt="在这里插入图片描述" width="650" height="97"></a><br> 2、新建readme.txt,Dockerfile文件 ,并且填写dockerfile指令(这里我们是要建一个tomcat 和jdk的镜像),随后构建写好的dockerfile文件</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># touch readme.txt</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># vi Dockerfile</span>

<span class="token comment"># 填写dockerfile指令,这里我们是要建一个tomcat 和jdk的镜像</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># cat Dockerfile </span>
<span class="token keyword">FROM</span> centos:7
MAINTAINER chenxiansheng<1050480930@qq<span class="token punctuation">.</span>com>

<span class="token function">COPY</span> readme<span class="token punctuation">.</span>txt <span class="token operator">/</span>usr/local/readme<span class="token punctuation">.</span>txt

ADD jdk-8u60-linux-x64<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz <span class="token operator">/</span>usr/local/
ADD apache-tomcat-9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>63<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz <span class="token operator">/</span>usr/local/

RUN yum <span class="token operator">-</span>y install vim 

ENV MYPATH <span class="token operator">/</span>usr/local
WORKDIR <span class="token variable">$MYPATH</span>

ENV JAVA_HOME <span class="token operator">/</span>usr/local/jdk1<span class="token punctuation">.</span>8<span class="token punctuation">.</span>0_60
ENV CLASSPATH <span class="token variable">$JAVA_HOME</span><span class="token operator">/</span>lib/dt<span class="token punctuation">.</span>jar:<span class="token variable">$JAVA_HOME</span><span class="token operator">/</span>lib/tools<span class="token punctuation">.</span>jar
ENV CATALINA_HOME <span class="token operator">/</span>usr/local/apache-tomcat-9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>63
ENV CATALINA_BASH <span class="token operator">/</span>usr/local/apache-tomcat-9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>63
ENV PATH <span class="token variable">$PATH</span>:<span class="token variable">$JAVA_HOME</span><span class="token operator">/</span>bin:<span class="token variable">$CATAINA_HOME</span><span class="token operator">/</span>lib:<span class="token variable">$CATALINA_HOME</span><span class="token operator">/</span>bin


EXPOSE 8080

CMD <span class="token operator">/</span>usr/local/apache-tomcat-9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>63/bin/startup<span class="token punctuation">.</span>sh && tail <span class="token operator">-</span>F <span class="token operator">/</span>usr/local/apache-tomcat-9<span class="token punctuation">.</span>0<span class="token punctuation">.</span>63/bin/logs/catalina<span class="token punctuation">.</span>out


<span class="token comment"># 开始构建dockerfile(这里的“.” 代表构建当前目录下的Dockfile文件)</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># docker build -t diytomcat .</span>
Sending build context to Docker daemon  192<span class="token punctuation">.</span>8MB
Step 1/15 : <span class="token keyword">FROM</span> centos:7
 <span class="token operator">--</span><span class="token operator">-</span>> eeb6ee3f44bd
Step 2/15 : MAINTAINER chenxiansheng<1050480930@qq<span class="token punctuation">.</span>com>
 <span class="token operator">--</span><span class="token operator">-</span>> <span class="token keyword">Using</span> cache
 <span class="token operator">--</span><span class="token operator">-</span>> 722b4df5b913
<span class="token comment">#....... 省略构建日志</span>
Successfully built 7c5296e1e145
Successfully tagged diytomcat:latest

<span class="token comment"># 查看镜像,可以发现,我们的diytomcat 构建成功</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># docker images</span>
REPOSITORY             TAG       IMAGE ID       CREATED         SIZE
diytomcat              latest    7c5296e1e145   2 minutes ago   811MB
</code></pre> 
  <p>第3步、启动该镜像</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># docker run -d -p 9090:8080 --name chenxianshengtomcat -v /home/tomcat/test:/usr/local/apache-tomcat-9.0.63/webapps/test -v /home/tomcat/tomcatlogs/:/usr/local/apache-tomcat-9.0.63/logs diytomcat</span>
49b22d1db8763cee40876a75a4ed11cebdc51462153f981253d1a04582cca618

</code></pre> 
  <p>镜像 启动参数说明:<br> <a href="http://img.e-com-net.com/image/info8/6079c56d1c4c49e3ba03d2049a8d87ad.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/6079c56d1c4c49e3ba03d2049a8d87ad.jpg" alt="Docker 入门流程_第21张图片" width="650" height="325" style="border:1px solid black;"></a><a href="http://img.e-com-net.com/image/info8/401fae900dfa4e918063d12c67a43a12.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/401fae900dfa4e918063d12c67a43a12.jpg" alt="" width="650" height="85"></a></p> 
  <p>第4步,开始测试,tomcat是否成功</p> 
  <p>直接去访问linux地址的9090端口,查看是否有tomcat 页面:<br> <a href="http://img.e-com-net.com/image/info8/98fa1738c1a74784b466fb751728908b.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/98fa1738c1a74784b466fb751728908b.jpg" alt="Docker 入门流程_第22张图片" width="650" height="555" style="border:1px solid black;"></a><br> 可以看到,tomcat是正常运行的</p> 
  <p>第五步。继续测试tomcat ,因为我们在启动自己制作的diytomcat镜像时,将本机的/home/tomcat/test 目录与容器里面的/usr/local/apache-tomcat-9.0.63/webapps/test 绑定了,所以,我们直接往本机的/home/tomcat/test 目录,新增index.jsp ,那么容器的apache-tomcat-9.0.63/webapps/test 目录也是会有index.jsp文件的,这时候去访问本机地址:9090/test 地址,是会识别到index.jsp文件的,并把里面的内容解析成网页的。</p> 
  <p>1)进入到本机的/home/tomcat/test目录,新建index.jsp ,并且填上内容:</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># cd test/</span>
<span class="token namespace">[root@localhost test]</span><span class="token comment"># vi index.jsp</span>
<span class="token namespace">[root@localhost test]</span><span class="token comment"># cat index.jsp </span>
<<span class="token operator">%</span>@ page language=<span class="token string">"java"</span> contentType=<span class="token string">"text/html; charset=UTF-8"</span>
    pageEncoding=<span class="token string">"UTF-8"</span><span class="token operator">%</span>>
<<span class="token operator">!</span>DOCTYPE html>
<html>
<head>
<meta charset=<span class="token string">"utf-8"</span>>
<title>chenxiansheng<span class="token punctuation">(</span>runoob<span class="token punctuation">.</span>com<span class="token punctuation">)</span><<span class="token operator">/</span>title>
<<span class="token operator">/</span>head>
<body>
Hello World<span class="token punctuation">,</span>chenxiansheng!<br/>
<<span class="token operator">%</span>
out<span class="token punctuation">.</span>println<span class="token punctuation">(</span><span class="token string">"--------my test web logs-------"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">%</span>>
<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>

<span class="token comment"># 查看该容器是否也同步了index.jsp文件,可以看到同步成功</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment"># docker exec -it 49b22d1db8763 /bin/bash</span>
<span class="token namespace">[root@49b22d1db876 local]</span><span class="token comment"># cd /usr/local/apache-tomcat-9.0.63/webapps/test/</span>
<span class="token namespace">[root@49b22d1db876 test]</span><span class="token comment"># ls</span>
index<span class="token punctuation">.</span>jsp
</code></pre> 
  <p>2) 直接访问本地地址:9090/test 路径<br> <a href="http://img.e-com-net.com/image/info8/b6ee6396cb9b4399978f1721e46bd833.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/b6ee6396cb9b4399978f1721e46bd833.jpg" alt="Docker 入门流程_第23张图片" width="641" height="257" style="border:1px solid black;"></a><br> 可以看到,容器里面的tomcat正确的解析了index.jsp文件,生成了网页。并且我们可以去本机查看容器里面的logs日志(这个也是在启动该镜像的时候绑定好的)</p> 
  <p><a href="http://img.e-com-net.com/image/info8/8a006d11dc8c430c8cc57b5aea9ec75e.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/8a006d11dc8c430c8cc57b5aea9ec75e.jpg" alt="Docker 入门流程_第24张图片" width="650" height="286" style="border:1px solid black;"></a></p> 
  <blockquote> 
   <p>结论1:该diytomcat镜像,是我们自己一手打造出来的,实现了tomcat镜像该有的功能。</p> 
  </blockquote> 
  <blockquote> 
   <p>结论2:通过这种双向绑定的方式,我们的linux本机不需要安装tomcat镜像,只需要将其中的一个目录绑定在有tomcat的docker容器里,我们就可以实现,在本机上传web工程,让docker容器解析的功能。</p> 
  </blockquote> 
  <h2>发布自己的镜像</h2> 
  <p>1、地址 https://hub.docker.com/ 注册自己账号<br> 2、确定这个账号可以登录<br> 3、在我们的服务器上提交自己的镜像</p> 
  <pre><code class="prism language-powershell"><span class="token comment"># 使用docker login 命令 </span>
<span class="token namespace">[root@localhost tomcatlogs]</span><span class="token comment"># docker login -u morningchan</span>
Password: 
WARNING! Your password will be stored unencrypted in <span class="token operator">/</span>root/<span class="token punctuation">.</span>docker/config<span class="token punctuation">.</span>json<span class="token punctuation">.</span>
Configure a credential helper to remove this warning<span class="token punctuation">.</span> See
https:<span class="token operator">/</span><span class="token operator">/</span>docs<span class="token punctuation">.</span>docker<span class="token punctuation">.</span>com/engine/reference/commandline/login/<span class="token comment">#credentials-store</span>

Login Succeeded
<span class="token namespace">[root@localhost tomcatlogs]</span><span class="token comment"># </span>
</code></pre> 
  <p>登录成功后,需要修改tag ,也就是给自己的镜像一个版本号,使用docker tag 命令</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost tomcatlogs]</span><span class="token comment"># docker tag  7c5296e1e145 morningchan/diytomcat:1.0</span>
</code></pre> 
  <p>推送自己的镜像到docker hub ,使用docker push 命令</p> 
  <pre><code class="prism language-powershell"><span class="token namespace">[root@localhost tomcatlogs]</span><span class="token comment"># docker push morning/diytomcat:1.0</span>
</code></pre> 
  <blockquote> 
   <p>注意:修改tag的时候,最好修改成自己dockerhub 用户名字/ 镜像名称的形式, 如果前面用户自己的docker hub镜像命名,那后面push就会被拒绝。 这里我的docker hub 用户名就叫morningchan ,</p> 
  </blockquote> 
  <p>可以看到,push 成功(这里速度太慢了,毕竟国外的网站)<br> <a href="http://img.e-com-net.com/image/info8/e8456c0ad2464921a33f571019c1a279.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/e8456c0ad2464921a33f571019c1a279.jpg" alt="Docker 入门流程_第25张图片" width="650" height="159" style="border:1px solid black;"></a></p> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1647490186856140800"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(docker,容器,运维)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835502578050363392.htm"
                           title="PHP环境搭建详细教程" target="_blank">PHP环境搭建详细教程</a>
                        <span class="text-muted">好看资源平台</span>
<a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/php/1.htm">php</a>
                        <div>PHP是一个流行的服务器端脚本语言,广泛用于Web开发。为了使PHP能够在本地或服务器上运行,我们需要搭建一个合适的PHP环境。本教程将结合最新资料,介绍在不同操作系统上搭建PHP开发环境的多种方法,包括Windows、macOS和Linux系统的安装步骤,以及本地和Docker环境的配置。1.PHP环境搭建概述PHP环境的搭建主要分为以下几类:集成开发环境:例如XAMPP、WAMP、MAMP,这</div>
                    </li>
                    <li><a href="/article/1835495770502033408.htm"
                           title="Day17笔记-高阶函数" target="_blank">Day17笔记-高阶函数</a>
                        <span class="text-muted">~在杰难逃~</span>
<a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/pycharm/1.htm">pycharm</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a>
                        <div>高阶函数【重点掌握】函数的本质:函数是一个变量,函数名是一个变量名,一个函数可以作为另一个函数的参数或返回值使用如果A函数作为B函数的参数,B函数调用完成之后,会得到一个结果,则B函数被称为高阶函数常用的高阶函数:map(),reduce(),filter(),sorted()1.map()map(func,iterable),返回值是一个iterator【容器,迭代器】func:函数iterab</div>
                    </li>
                    <li><a href="/article/1835485429059645440.htm"
                           title="docker" target="_blank">docker</a>
                        <span class="text-muted">igotyback</span>
<a class="tag" taget="_blank" href="/search/eureka/1.htm">eureka</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>Docker容器的文件系统是隔离的,但是可以通过挂载卷(Volumes)或绑定挂载(BindMounts)将宿主机的文件系统目录映射到容器内部。要查看Docker容器的映射路径,可以使用以下方法:查看容器配置:使用dockerinspect命令可以查看容器的详细配置信息,包括挂载的卷。例如:bashdockerinspect在输出的JSON格式中,查找"Mounts"部分,这里会列出所有的挂载信息</div>
                    </li>
                    <li><a href="/article/1835457442260021248.htm"
                           title="ArrayList 源码解析" target="_blank">ArrayList 源码解析</a>
                        <span class="text-muted">程序猿进阶</span>
<a class="tag" taget="_blank" href="/search/Java%E5%9F%BA%E7%A1%80/1.htm">Java基础</a><a class="tag" taget="_blank" href="/search/ArrayList/1.htm">ArrayList</a><a class="tag" taget="_blank" href="/search/List/1.htm">List</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/1.htm">性能优化</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1/1.htm">架构设计</a><a class="tag" taget="_blank" href="/search/idea/1.htm">idea</a>
                        <div>ArrayList是Java集合框架中的一个动态数组实现,提供了可变大小的数组功能。它继承自AbstractList并实现了List接口,是顺序容器,即元素存放的数据与放进去的顺序相同,允许放入null元素,底层通过数组实现。除该类未实现同步外,其余跟Vector大致相同。每个ArrayList都有一个容量capacity,表示底层数组的实际大小,容器内存储元素的个数不能多于当前容量。当向容器中添</div>
                    </li>
                    <li><a href="/article/1835447859219099648.htm"
                           title="06选课支付模块之基于消息队列发送支付通知消息" target="_blank">06选课支付模块之基于消息队列发送支付通知消息</a>
                        <span class="text-muted">echo 云清</span>
<a class="tag" taget="_blank" href="/search/%E5%AD%A6%E6%88%90%E5%9C%A8%E7%BA%BF/1.htm">学成在线</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/rabbitmq/1.htm">rabbitmq</a><a class="tag" taget="_blank" href="/search/%E6%B6%88%E6%81%AF%E9%98%9F%E5%88%97/1.htm">消息队列</a><a class="tag" taget="_blank" href="/search/%E6%94%AF%E4%BB%98%E9%80%9A%E7%9F%A5/1.htm">支付通知</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E6%88%90%E5%9C%A8%E7%BA%BF/1.htm">学成在线</a>
                        <div>消息队列发送支付通知消息需求分析订单服务作为通用服务,在订单支付成功后需要将支付结果异步通知给其他对接的微服务,微服务收到支付结果根据订单的类型去更新自己的业务数据技术方案使用消息队列进行异步通知需要保证消息的可靠性即生产端将消息成功通知到服务端:消息发送到交换机-->由交换机发送到队列-->消费者监听队列,收到消息进行处理,参考文章02-使用Docker安装RabbitMQ-CSDN博客生产者确</div>
                    </li>
                    <li><a href="/article/1835422770016645120.htm"
                           title="《 C++ 修炼全景指南:四 》揭秘 C++ List 容器背后的实现原理,带你构建自己的双向链表" target="_blank">《 C++ 修炼全景指南:四 》揭秘 C++ List 容器背后的实现原理,带你构建自己的双向链表</a>
                        <span class="text-muted">Lenyiin</span>
<a class="tag" taget="_blank" href="/search/%E6%8A%80%E6%9C%AF%E6%8C%87%E5%8D%97/1.htm">技术指南</a><a class="tag" taget="_blank" href="/search/C%2B%2B/1.htm">C++</a><a class="tag" taget="_blank" href="/search/%E4%BF%AE%E7%82%BC%E5%85%A8%E6%99%AF%E6%8C%87%E5%8D%97/1.htm">修炼全景指南</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/list/1.htm">list</a><a class="tag" taget="_blank" href="/search/%E9%93%BE%E8%A1%A8/1.htm">链表</a><a class="tag" taget="_blank" href="/search/stl/1.htm">stl</a>
                        <div>本篇博客,我们将详细讲解如何从头实现一个功能齐全且强大的C++List容器,并深入到各个细节。这篇博客将包括每一步的代码实现、解释以及扩展功能的探讨,目标是让初学者也能轻松理解。一、简介1.1、背景介绍在C++中,std::list是一个基于双向链表的容器,允许高效的插入和删除操作,适用于频繁插入和删除操作的场景。与动态数组不同,list允许常数时间内的插入和删除操作,支持双向遍历。这篇文章将详细</div>
                    </li>
                    <li><a href="/article/1835408447806468096.htm"
                           title="Ubuntu18.04 Docker部署Kinship(Django)项目过程" target="_blank">Ubuntu18.04 Docker部署Kinship(Django)项目过程</a>
                        <span class="text-muted">Dante617</span>

                        <div>1Docker的安装https://blog.csdn.net/weixin_41735055/article/details/1003551792下载镜像dockerpullprogramize/python3.6.8-dlib下载的镜像里包含python3.6.8和dlib19.17.03启动镜像dockerrun-it--namekinship-p7777:80-p3307:3306-p55</div>
                    </li>
                    <li><a href="/article/1835399957885054976.htm"
                           title="docker from指令的含义_多个FROM-含义" target="_blank">docker from指令的含义_多个FROM-含义</a>
                        <span class="text-muted">weixin_39722188</span>
<a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/from%E6%8C%87%E4%BB%A4%E7%9A%84%E5%90%AB%E4%B9%89/1.htm">from指令的含义</a>
                        <div>小编典典什么是基本图片?一组文件,加上EXPOSE端口ENTRYPOINT和CMD。您可以添加文件并基于该基础图像构建新图像,Dockerfile并以FROM指令开头:后面提到的图像FROM是新图像的“基础图像”。这是否意味着如果我neo4j/neo4j在FROM指令中声明,则在运行映像时,neo数据库将自动运行并且可在端口7474的容器中使用?仅当您不覆盖CMD和时ENTRYPOINT。但是图像</div>
                    </li>
                    <li><a href="/article/1835399831116410880.htm"
                           title="Dockerfile FROM 两个" target="_blank">Dockerfile FROM 两个</a>
                        <span class="text-muted">redDelta</span>

                        <div>Docker相关视频讲解:什么是容器Docker介绍实现"DockerfileFROM两个"的步骤步骤表格步骤操作1创建一个Dockerfile文件2写入FROM指令3构建第一个镜像4创建第二个Dockerfile文件5写入FROM指令6构建第二个镜像7合并两个镜像操作步骤说明步骤1:创建一个Dockerfile文件使用任意文本编辑器创建一个名为Dockerfile的文件。登录后复制#Docker</div>
                    </li>
                    <li><a href="/article/1835395039572881408.htm"
                           title="Dockerfile命令详解之 FROM" target="_blank">Dockerfile命令详解之 FROM</a>
                        <span class="text-muted">清风怎不知意</span>
<a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8%E5%8C%96/1.htm">容器化</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a>
                        <div>许多同学不知道Dockerfile应该如何写,不清楚Dockerfile中的指令分别有什么意义,能达到什么样的目的,接下来我将在容器化专栏中详细的为大家解释每一个指令的含义以及用法。专栏订阅传送门https://blog.csdn.net/qq_38220908/category_11989778.html指令不区分大小写。但是,按照惯例,它们应该是大写的,以便更容易地将它们与参数区分开来。(引用</div>
                    </li>
                    <li><a href="/article/1835394786899619840.htm"
                           title="Dockerfile(1) - FROM 指令详解" target="_blank">Dockerfile(1) - FROM 指令详解</a>
                        <span class="text-muted">小菠萝测试笔记</span>
<a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/cmd/1.htm">cmd</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a>
                        <div>FROM指明当前的镜像基于哪个镜像构建dockerfile必须以FROM开头,除了ARG命令可以在FROM前面FROM[--platform=][AS]FROM[--platform=][:][AS]FROM[--platform=][@][AS]小栗子FROMalpine:latest一个dockerfile可以有多个FROM可以有多个FROM来创建多个镜像,或区分构建阶段,将一个构建阶段作为另</div>
                    </li>
                    <li><a href="/article/1835387473346260992.htm"
                           title="2020年最新程序员职业发展路线指南,超详细!" target="_blank">2020年最新程序员职业发展路线指南,超详细!</a>
                        <span class="text-muted">编程流川枫</span>
<a class="tag" taget="_blank" href="/search/11/1.htm">11</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/1.htm">编程语言</a><a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/%E4%BA%92%E8%81%94%E7%BD%91/1.htm">互联网</a><a class="tag" taget="_blank" href="/search/IT/1.htm">IT</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E4%B8%9A/1.htm">职业</a>
                        <div>【文章来源微信公众号:每天学编程】01、程序员的特性技术出身的职场人特性很明显,与做市场、业务出身的职场人区别尤其明显。IT行业中常见的一些职场角色:老板、项目经理、产品经理、需求分析师、设计师、开发工程师、运维工程师等。开发工程师具有如下特征:1、逻辑思维清晰、严谨和细腻;但是有时不容易转弯,有些程序员容易较劲、钻牛角尖。2、性格偏内向、不善于沟通、表达和交际;但是在网络聊天工具上,有些显为幽默</div>
                    </li>
                    <li><a href="/article/1835379662918873088.htm"
                           title="【从问题中去学习k8s】k8s中的常见面试题(夯实理论基础)(二十八)" target="_blank">【从问题中去学习k8s】k8s中的常见面试题(夯实理论基础)(二十八)</a>
                        <span class="text-muted">向往风的男子</span>
<a class="tag" taget="_blank" href="/search/k8s/1.htm">k8s</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>本站以分享各种运维经验和运维所需要的技能为主《python零基础入门》:python零基础入门学习《python运维脚本》:python运维脚本实践《shell》:shell学习《terraform》持续更新中:terraform_Aws学习零基础入门到最佳实战《k8》从问题中去学习k8s《docker学习》暂未更新《ceph学习》ceph日常问题解决分享《日志收集》ELK+各种中间件《运维日常》</div>
                    </li>
                    <li><a href="/article/1835379083945537536.htm"
                           title="leetcode 11. 盛最多水的容器" target="_blank">leetcode 11. 盛最多水的容器</a>
                        <span class="text-muted">Source_Chang</span>

                        <div>leetcode核心思想:双指针,数字小的那个指针移动classSolution{public:intmaxArea(vector&height){intleft=0;intright=height.size()-1;intmaxArea=0;while(left<right){maxArea=max(min(height[left],height[right])*(right-left),max</div>
                    </li>
                    <li><a href="/article/1835375621996376064.htm"
                           title="Kubernetes数据持久化" target="_blank">Kubernetes数据持久化</a>
                        <span class="text-muted">看清所苡看轻</span>
<a class="tag" taget="_blank" href="/search/kubernetes%28k8s%29/1.htm">kubernetes(k8s)</a><a class="tag" taget="_blank" href="/search/emptyDir/1.htm">emptyDir</a><a class="tag" taget="_blank" href="/search/HostPath/1.htm">HostPath</a><a class="tag" taget="_blank" href="/search/pv/1.htm">pv</a><a class="tag" taget="_blank" href="/search/pvc/1.htm">pvc</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>在k8s中,Volume(数据卷)存在明确的生命周期(与包含该数据卷的容器组(pod)相同)。因此Volume的生命周期比同一容器组(pod)中任意容器的生命周期要更长,不管容器重启了多少次,数据都被保留下来。当然,如果pod不存在了,数据卷自然退出了。此时,根据pod所使用的数据卷类型不同,数据可能随着数据卷的退出而删除,也可能被真正持久化,并在下次容器组重启时仍然可以使用。从根本上来说,一个数</div>
                    </li>
                    <li><a href="/article/1835364027488890880.htm"
                           title="leetcode刷题day13|二叉树Part01(递归遍历、迭代遍历、统一迭代、层序遍历)" target="_blank">leetcode刷题day13|二叉树Part01(递归遍历、迭代遍历、统一迭代、层序遍历)</a>
                        <span class="text-muted">小冉在学习</span>
<a class="tag" taget="_blank" href="/search/leetcode/1.htm">leetcode</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>递归遍历思路:使用递归的方式比较简单。1、递归函数的传参:因为最后输出一个数组,所以需要传入根节点和一个容器,本来想写数组,但发现长度不能确定,所以选择list。2、终止条件:当访问的节点为空时,return3、递归函数的逻辑:先访问一个节点,递归访问其他节点144.二叉树的前序遍历代码如下:classSolution{publicListpreorderTraversal(TreeNoderoo</div>
                    </li>
                    <li><a href="/article/1835354574077128704.htm"
                           title="Kubernetes的3种数据持久化方式" target="_blank">Kubernetes的3种数据持久化方式</a>
                        <span class="text-muted">Seal^_^</span>
<a class="tag" taget="_blank" href="/search/%E3%80%90%E4%BA%91%E5%8E%9F%E7%94%9F%E3%80%91%E5%AE%B9%E5%99%A8%E5%8C%96%E4%B8%8E%E7%BC%96%E6%8E%92%E6%8A%80%E6%9C%AF/1.htm">【云原生】容器化与编排技术</a><a class="tag" taget="_blank" href="/search/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90/1.htm">持续集成</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/EmptyDir/1.htm">EmptyDir</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/HostPath/1.htm">HostPath</a>
                        <div>Kubernetes的3种数据持久化方式1.EmptyDir2.HostPath3.PersistentVolume(PV)TheBegin点点关注,收藏不迷路Kubernetes提供了几种数据持久化方式,以满足不同场景的需求:1.EmptyDir用途:临时数据存储,Pod内容器间共享。特点:生命周期与Pod相同,Pod删除时数据也删除。2.HostPath用途:访问宿主机特定文件或目录。特点:增</div>
                    </li>
                    <li><a href="/article/1835337427720433664.htm"
                           title="ruby和python哪个好学" target="_blank">ruby和python哪个好学</a>
                        <span class="text-muted">hakesashou</span>
<a class="tag" taget="_blank" href="/search/python%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/1.htm">python基础知识</a><a class="tag" taget="_blank" href="/search/ruby/1.htm">ruby</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>Ruby和python都挺好学的。建议学习Python,语法的话,Python相对更简洁。而且Python应用场合更广泛,运维、网站开发、数据处理、科学研究都可以。Ruby和Python十分相似,有很多共同点,但也有一些不同之外,以下是Python和Ruby的对比:1、Python和Ruby都是面向对象的语言,都是动态和灵活的。二者的主要区别在于他们解决问题的方式。Ruby提供了不同的方法,而Py</div>
                    </li>
                    <li><a href="/article/1835331377520799744.htm"
                           title="【K8s】专题十一:Kubernetes 集群证书过期处理方法" target="_blank">【K8s】专题十一:Kubernetes 集群证书过期处理方法</a>
                        <span class="text-muted">行者Sun1989</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>本文内容均来自个人笔记并重新梳理,如有错误欢迎指正!如果对您有帮助,烦请点赞、关注、转发、订阅专栏!专栏订阅入口Linux专栏|Docker专栏|Kubernetes专栏往期精彩文章【Docker】(全网首发)KylinV10下MySQL容器内存占用异常的解决方法【Docker】(全网首发)KylinV10下MySQL容器内存占用异常的解决方法(续)【Docker】MySQL源码构建Docker镜</div>
                    </li>
                    <li><a href="/article/1835310380474265600.htm"
                           title="Java面试笔记记录6" target="_blank">Java面试笔记记录6</a>
                        <span class="text-muted">今天背八股了吗</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a>
                        <div>1.Spring是什么?特性?有哪些模块?Spring是一个轻量级、非入侵式的控制反转Ioc和面向切面AOP的框架。特性:1.Ioc和DISpring的核心就是一个大的工厂容器,可以维护所有对象的创建和依赖关系,Spring工厂用于生成Bean,并且管理Bean的生命周期,实现高内聚低耦合的设计理念。2.AOP编程Spring提供面向切面编程,可以方便实现对程序进行权限拦截、运行监控等切面功能。3</div>
                    </li>
                    <li><a href="/article/1835269935358636032.htm"
                           title="Docker学习十一:Kubernetes概述" target="_blank">Docker学习十一:Kubernetes概述</a>
                        <span class="text-muted">爱打羽球的程序猿</span>
<a class="tag" taget="_blank" href="/search/Docker%E5%AD%A6%E4%B9%A0%E7%B3%BB%E5%88%97/1.htm">Docker学习系列</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a>
                        <div>一、Kubernetes简介2006年,Google提出了云计算的概念,当时的云计算领域还是以虚拟机为代表的云平台。2013年,Docker横空出世,Docker提出了镜像、仓库等核心概念,规范了服务的交付标准,使得复杂服务的落地变得更加简单,之后Docker又定义了OCI标准,Docker在容器领域称为事实的标准。但是,Docker诞生只是帮助定义了开发和交付标准,如果想要在生产环境中大批量的使</div>
                    </li>
                    <li><a href="/article/1835267918531751936.htm"
                           title="安装 `privoxy` 将 Socks5 转换为 HTTP 代理" target="_blank">安装 `privoxy` 将 Socks5 转换为 HTTP 代理</a>
                        <span class="text-muted">MonkeyKing.sun</span>
<a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a>
                        <div>(base)shgbitai@shgbitai-C9X299-PGF:~/tools$curl-xhttp://127.0.0.1:1080https://registry-1.docker.io/v2/curl:(56)ProxyCONNECTaborted(base)shgbitai@shgbitai-C9X299-PGF:~/tools$curl-xhttps://127.0.0.1:108</div>
                    </li>
                    <li><a href="/article/1835267665455837184.htm"
                           title="Halo 开发者指南——容器私有化部署" target="_blank">Halo 开发者指南——容器私有化部署</a>
                        <span class="text-muted">SHENHUANJIE</span>
<a class="tag" taget="_blank" href="/search/Docker/1.htm">Docker</a><a class="tag" taget="_blank" href="/search/Halo/1.htm">Halo</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BA%E4%BA%91/1.htm">华为云</a><a class="tag" taget="_blank" href="/search/SWR/1.htm">SWR</a><a class="tag" taget="_blank" href="/search/Registry/1.htm">Registry</a>
                        <div>华为云SWR私有化部署镜像构建dockerbuild-thalo-dev/halo:2.20.0.上传镜像镜像标签sudodockertag{镜像名称}:{版本名称}swr.cn-south-1.myhuaweicloud.com/{组织名称}/{镜像名称}:{版本名称}sudodockertaghalo-dev/halo:2.20.0swr.cn-south-1.myhuaweicloud.co</div>
                    </li>
                    <li><a href="/article/1835262244313722880.htm"
                           title="SpringBoot整合ES搜索引擎 实现网站热搜词及热度计算" target="_blank">SpringBoot整合ES搜索引擎 实现网站热搜词及热度计算</a>
                        <span class="text-muted">码踏云端</span>
<a class="tag" taget="_blank" href="/search/springboot/1.htm">springboot</a><a class="tag" taget="_blank" href="/search/Elasticsearch/1.htm">Elasticsearch</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/elasticsearch/1.htm">elasticsearch</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a><a class="tag" taget="_blank" href="/search/%E7%83%AD%E6%90%9C%E8%AF%8D/1.htm">热搜词</a><a class="tag" taget="_blank" href="/search/%E7%83%AD%E5%BA%A6%E8%AE%A1%E7%AE%97/1.htm">热度计算</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>博主简介:历代文学网(PC端可以访问:https://literature.sinhy.com/#/literature?__c=1000,移动端可微信小程序搜索“历代文学”)总架构师,15年工作经验,精通Java编程,高并发设计,Springboot和微服务,熟悉Linux,ESXI虚拟化以及云原生Docker和K8s,热衷于探索科技的边界,并将理论知识转化为实际应用。保持对新技术的好奇心,乐于</div>
                    </li>
                    <li><a href="/article/1835260726516740096.htm"
                           title="华为云分布式缓存服务DCS与开源服务差异对比" target="_blank">华为云分布式缓存服务DCS与开源服务差异对比</a>
                        <span class="text-muted">hcinfo_18</span>
<a class="tag" taget="_blank" href="/search/redis%E4%BD%BF%E7%94%A8/1.htm">redis使用</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BA%E4%BA%91/1.htm">华为云</a><a class="tag" taget="_blank" href="/search/Redis5.0/1.htm">Redis5.0</a><a class="tag" taget="_blank" href="/search/%E5%88%86%E5%B8%83%E5%BC%8F%E7%BC%93%E5%AD%98%E6%9C%8D%E5%8A%A1/1.htm">分布式缓存服务</a><a class="tag" taget="_blank" href="/search/Redis%E5%AE%A2%E6%88%B7%E7%AB%AF/1.htm">Redis客户端</a>
                        <div>分布式缓存服务DCS提供单机、主备、集群等丰富的实例类型,满足用户高读写性能及快速数据访问的业务诉求。支持丰富的实例管理操作,帮助用户省去运维烦恼。用户可以聚焦于业务逻辑本身,而无需过多考虑部署、监控、扩容、安全、故障恢复等方面的问题。DCS基于开源Redis、Memcached向用户提供一定程度定制化的缓存服务,因此,除了拥有开源服务缓存数据库的优秀特性,DCS提供更多实用功能。一、与开源Red</div>
                    </li>
                    <li><a href="/article/1835259969000271872.htm"
                           title="软件测试/测试开发/全日制 |利用Django REST framework构建微服务" target="_blank">软件测试/测试开发/全日制 |利用Django REST framework构建微服务</a>
                        <span class="text-muted">霍格沃兹-慕漓</span>
<a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E5%BE%AE%E6%9C%8D%E5%8A%A1/1.htm">微服务</a><a class="tag" taget="_blank" href="/search/sqlite/1.htm">sqlite</a>
                        <div>霍格沃兹测试开发学社推出了《Python全栈开发与自动化测试班》。本课程面向开发人员、测试人员与运维人员,课程内容涵盖Python编程语言、人工智能应用、数据分析、自动化办公、平台开发、UI自动化测试、接口测试、性能测试等方向。为大家提供更全面、更深入、更系统化的学习体验,课程还增加了名企私教服务内容,不仅有名企经理为你1v1辅导,还有行业专家进行技术指导,针对性地解决学习、工作中遇到的难题。让找</div>
                    </li>
                    <li><a href="/article/1835259716809355264.htm"
                           title="小白 | 华为云docker设置镜像加速器" target="_blank">小白 | 华为云docker设置镜像加速器</a>
                        <span class="text-muted">伏一</span>
<a class="tag" taget="_blank" href="/search/%E5%B7%A5%E5%85%B7%E5%AE%89%E8%A3%85/1.htm">工具安装</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BA%E4%BA%91/1.htm">华为云</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>一、操作场景通过dockerpull命令下载镜像中心的公有镜像时,往往会因为网络原因而需要很长时间,甚至可能因超时而下载失败。为此,容器镜像服务提供了镜像下载加速功能,帮助您获得更快的下载体验。二、约束与限制构建镜像的客户端所安装的容器引擎(Docker)版本必须为1.11.2及以上。“华北-乌兰察布一”、“亚太-雅加达”、“拉美-墨西哥城一”、“拉美-墨西哥城二”和“拉美-圣保罗一”区域不支持该</div>
                    </li>
                    <li><a href="/article/1835245099416645632.htm"
                           title="docker改容器IP的两种方法" target="_blank">docker改容器IP的两种方法</a>
                        <span class="text-muted">redmond88</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/tcp%2Fip/1.htm">tcp/ip</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>最简单实用的方法:docker默认的内网网段为172.17.0.0/16,如果公司内网网段也是172.17.x.x的话,就会发生路由冲突。解决办法改路由比较办法,可以一开始就将docker配置的bip改成169.254.0.1/24,可以避免冲突。在daemon配置文件里加个"bip":“169.254.0.1/24”,重启docker就可以了1234[root@st-dev6~]#vim/etc</div>
                    </li>
                    <li><a href="/article/1835225687028494336.htm"
                           title="java获取applicationcontext,SpringBoot获取ApplicationContext的3种方式" target="_blank">java获取applicationcontext,SpringBoot获取ApplicationContext的3种方式</a>
                        <span class="text-muted">花儿街参考</span>

                        <div>ApplicationContext是什么?简单来说就是Spring中的容器,可以用来获取容器中的各种bean组件,注册监听事件,加载资源文件等功能。ApplicationContext获取的几种方式1直接使用Autowired注入@ComponentpublicclassBook1{@AutowiredprivateApplicationContextapplicationContext;pub</div>
                    </li>
                    <li><a href="/article/1835209173944594432.htm"
                           title="(k8s)Kubernetes 从0到1容器编排之旅" target="_blank">(k8s)Kubernetes 从0到1容器编排之旅</a>
                        <span class="text-muted">道不贱卖,法不轻传</span>
<a class="tag" taget="_blank" href="/search/kubernets/1.htm">kubernets</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>一、引言在当今数字化的浪潮中,Kubernetes如同一艘强大的航船,引领着容器化应用的部署与管理。它以其卓越的灵活性、可扩展性和可靠性,成为众多企业和开发者的首选。然而,要真正发挥Kubernetes的强大威力,仅仅掌握基本操作是远远不够的。本文将带你深入探索Kubernetes使用过程中的奇技妙法,为你开启一段优雅的容器编排之旅。二、高级资源管理之精妙艺术1.资源配额与限制:雕琢资源之美•Ku</div>
                    </li>
                                <li><a href="/article/92.htm"
                                       title="log4j对象改变日志级别" target="_blank">log4j对象改变日志级别</a>
                                    <span class="text-muted">3213213333332132</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/log4j/1.htm">log4j</a><a class="tag" taget="_blank" href="/search/level/1.htm">level</a><a class="tag" taget="_blank" href="/search/log4j%E5%AF%B9%E8%B1%A1%E5%90%8D%E7%A7%B0/1.htm">log4j对象名称</a><a class="tag" taget="_blank" href="/search/%E6%97%A5%E5%BF%97%E7%BA%A7%E5%88%AB/1.htm">日志级别</a>
                                    <div>log4j对象改变日志级别可批量的改变所有级别,或是根据条件改变日志级别。 
 
log4j配置文件: 
 
 

log4j.rootLogger=ERROR,FILE,CONSOLE,EXECPTION
 
#log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE=org.apache.l</div>
                                </li>
                                <li><a href="/article/219.htm"
                                       title="elk+redis 搭建nginx日志分析平台" target="_blank">elk+redis 搭建nginx日志分析平台</a>
                                    <span class="text-muted">ronin47</span>
<a class="tag" taget="_blank" href="/search/elasticsearch/1.htm">elasticsearch</a><a class="tag" taget="_blank" href="/search/kibana/1.htm">kibana</a><a class="tag" taget="_blank" href="/search/logstash/1.htm">logstash</a>
                                    <div>              elk+redis 搭建nginx日志分析平台 
logstash,elasticsearch,kibana 怎么进行nginx的日志分析呢?首先,架构方面,nginx是有日志文件的,它的每个请求的状态等都有日志文件进行记录。其次,需要有个队 列,redis的l</div>
                                </li>
                                <li><a href="/article/346.htm"
                                       title="Yii2设置时区" target="_blank">Yii2设置时区</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/timezone/1.htm">timezone</a><a class="tag" taget="_blank" href="/search/yii2/1.htm">yii2</a>
                                    <div>时区这东西,在开发的时候,你说重要吧,也还好,毕竟没它也能正常运行,你说不重要吧,那就纠结了。特别是linux系统,都TMD差上几小时,你能不痛苦吗?win还好一点。有一些常规方法,是大家目前都在采用的1、php.ini中的设置,这个就不谈了,2、程序中公用文件里设置,date_default_timezone_set一下时区3、或者。。。自己写时间处理函数,在遇到时间的时候,用这个函数处理(比较</div>
                                </li>
                                <li><a href="/article/473.htm"
                                       title="js实现前台动态添加文本框,后台获取文本框内容" target="_blank">js实现前台动态添加文本框,后台获取文本框内容</a>
                                    <span class="text-muted">171815164</span>
<a class="tag" taget="_blank" href="/search/%E6%96%87%E6%9C%AC%E6%A1%86/1.htm">文本框</a>
                                    <div>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w</div>
                                </li>
                                <li><a href="/article/600.htm"
                                       title="持续集成工具" target="_blank">持续集成工具</a>
                                    <span class="text-muted">g21121</span>
<a class="tag" taget="_blank" href="/search/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90/1.htm">持续集成</a>
                                    <div>        持续集成是什么?我们为什么需要持续集成?持续集成带来的好处是什么?什么样的项目需要持续集成?...        持续集成(Continuous integration ,简称CI),所谓集成可以理解为将互相依赖的工程或模块合并成一个能单独运行</div>
                                </li>
                                <li><a href="/article/727.htm"
                                       title="数据结构哈希表(hash)总结" target="_blank">数据结构哈希表(hash)总结</a>
                                    <span class="text-muted">永夜-极光</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a>
                                    <div>1.什么是hash 
来源于百度百科: 
Hash,一般翻译做“散列”,也有直接音译为“哈希”的,就是把任意长度的输入,通过散列算法,变换成固定长度的输出,该输出就是散列值。这种转换是一种压缩映射,也就是,散列值的空间通常远小于输入的空间,不同的输入可能会散列成相同的输出,所以不可能从散列值来唯一的确定输入值。简单的说就是一种将任意长度的消息压缩到某一固定长度的消息摘要的函数。 
  
</div>
                                </li>
                                <li><a href="/article/854.htm"
                                       title="乱七八糟" target="_blank">乱七八糟</a>
                                    <span class="text-muted">程序员是怎么炼成的</span>

                                    <div>eclipse中的jvm字节码查看插件地址: 
http://andrei.gmxhome.de/eclipse/ 
安装该地址的outline 插件  后重启,打开window下的view下的bytecode视图 
http://andrei.gmxhome.de/eclipse/ 
  
jvm博客: 
http://yunshen0909.iteye.com/blog/2</div>
                                </li>
                                <li><a href="/article/981.htm"
                                       title="职场人伤害了“上司” 怎样弥补" target="_blank">职场人伤害了“上司” 怎样弥补</a>
                                    <span class="text-muted">aijuans</span>
<a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA/1.htm">职场</a>
                                    <div> 由于工作中的失误,或者平时不注意自己的言行“伤害”、“得罪”了自己的上司,怎么办呢? 
  在职业生涯中这种问题尽量不要发生。下面提供了一些解决问题的建议: 
  一、利用一些轻松的场合表示对他的尊重 
  即使是开明的上司也很注重自己的权威,都希望得到下属的尊重,所以当你与上司冲突后,最好让不愉快成为过去,你不妨在一些轻松的场合,比如会餐、联谊活动等,向上司问个好,敬下酒,表示你对对方的尊重,</div>
                                </li>
                                <li><a href="/article/1108.htm"
                                       title="深入浅出url编码" target="_blank">深入浅出url编码</a>
                                    <span class="text-muted">antonyup_2006</span>
<a class="tag" taget="_blank" href="/search/%E5%BA%94%E7%94%A8%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">应用服务器</a><a class="tag" taget="_blank" href="/search/%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">浏览器</a><a class="tag" taget="_blank" href="/search/servlet/1.htm">servlet</a><a class="tag" taget="_blank" href="/search/weblogic/1.htm">weblogic</a><a class="tag" taget="_blank" href="/search/IE/1.htm">IE</a>
                                    <div>出处:http://blog.csdn.net/yzhz  杨争   
http://blog.csdn.net/yzhz/archive/2007/07/03/1676796.aspx 
 
一、问题: 
        编码问题是JAVA初学者在web开发过程中经常会遇到问题,网上也有大量相关的</div>
                                </li>
                                <li><a href="/article/1235.htm"
                                       title="建表后创建表的约束关系和增加表的字段" target="_blank">建表后创建表的约束关系和增加表的字段</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/%E6%A0%87%E7%9A%84%E7%BA%A6%E6%9D%9F%E5%85%B3%E7%B3%BB/1.htm">标的约束关系</a><a class="tag" taget="_blank" href="/search/%E5%A2%9E%E5%8A%A0%E8%A1%A8%E7%9A%84%E5%AD%97%E6%AE%B5/1.htm">增加表的字段</a>
                                    <div>  
下面所有的操作都是在表建立后操作的,主要目的就是熟悉sql的约束,约束语句的万能公式 
  
1,增加字段(student表中增加 姓名字段) 
  
alter table 增加字段的表名 add  增加的字段名   增加字段的数据类型

  alter table student add name varchar2(10);
 
  
&nb</div>
                                </li>
                                <li><a href="/article/1362.htm"
                                       title="Uploadify 3.2 参数属性、事件、方法函数详解" target="_blank">Uploadify 3.2 参数属性、事件、方法函数详解</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/uploadify/1.htm">uploadify</a>
                                    <div>一.属性     
属性名称   
默认值   
说明     
auto   
true   
设置为true当选择文件后就直接上传了,为false需要点击上传按钮才上传。     
buttonClass   
”   
按钮样式     
buttonCursor   
‘hand’   
鼠标指针悬停在按钮上的样子     
buttonImage   
null   
浏览按钮的图片的路</div>
                                </li>
                                <li><a href="/article/1489.htm"
                                       title="精通Oracle10编程SQL(16)使用LOB对象" target="_blank">精通Oracle10编程SQL(16)使用LOB对象</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/plsql/1.htm">plsql</a>
                                    <div>/*
 *使用LOB对象
 */
--LOB(Large Object)是专门用于处理大对象的一种数据类型,其所存放的数据长度可以达到4G字节
--CLOB/NCLOB用于存储大批量字符数据,BLOB用于存储大批量二进制数据,而BFILE则存储着指向OS文件的指针

/*
 *综合实例
 */
--建立表空间 
--#指定区尺寸为128k,如不指定,区尺寸默认为64k 
CR</div>
                                </li>
                                <li><a href="/article/1616.htm"
                                       title="【Resin一】Resin服务器部署web应用" target="_blank">【Resin一】Resin服务器部署web应用</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/resin/1.htm">resin</a>
                                    <div>工作中,在Resin服务器上部署web应用,通常有如下三种方式: 
  
 
 配置多个web-app 
 配置多个http id 
 为每个应用配置一个propeties、xml以及sh脚本文件 
 配置多个web-app 
  
 
 在resin.xml中,可以为一个host配置多个web-app 
 
  
<cluster id="app&q</div>
                                </li>
                                <li><a href="/article/1743.htm"
                                       title="red5简介及基础知识" target="_blank">red5简介及基础知识</a>
                                    <span class="text-muted">白糖_</span>
<a class="tag" taget="_blank" href="/search/%E5%9F%BA%E7%A1%80/1.htm">基础</a>
                                    <div>  
 
 简介 
 
  
Red5的主要功能和Macromedia公司的FMS类似,提供基于Flash的流媒体服务的一款基于Java的开源流媒体服务器。它由Java语言编写,使用RTMP作为流媒体传输协议,这与FMS完全兼容。它具有流化FLV、MP3文件,实时录制客户端流为FLV文件,共享对象,实时视频播放、Remoting等功能。用Red5替换FMS后,客户端不用更改可正</div>
                                </li>
                                <li><a href="/article/1870.htm"
                                       title="angular.fromJson" target="_blank">angular.fromJson</a>
                                    <span class="text-muted">boyitech</span>
<a class="tag" taget="_blank" href="/search/AngularJS/1.htm">AngularJS</a><a class="tag" taget="_blank" href="/search/AngularJS+%E5%AE%98%E6%96%B9API/1.htm">AngularJS 官方API</a><a class="tag" taget="_blank" href="/search/AngularJS+API/1.htm">AngularJS API</a>
                                    <div>angular.fromJson   描述:   把Json字符串转为对象    使用方法:   angular.fromJson(json);   参数详解:      Param Type Details   json 
string  
JSON 字符串      返回值:   对象, 数组, 字符串 或者是一个数字   示例:   
<!DOCTYPE HTML>
<h</div>
                                </li>
                                <li><a href="/article/1997.htm"
                                       title="java-颠倒一个句子中的词的顺序。比如: I am a student颠倒后变成:student a am I" target="_blank">java-颠倒一个句子中的词的顺序。比如: I am a student颠倒后变成:student a am I</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>

public class ReverseWords {

	/**
	 * 题目:颠倒一个句子中的词的顺序。比如: I am a student颠倒后变成:student a am I.词以空格分隔。
	 * 要求:
	 * 1.实现速度最快,移动最少
	 * 2.不能使用String的方法如split,indexOf等等。
	 * 解答:两次翻转。
	 */
	publ</div>
                                </li>
                                <li><a href="/article/2124.htm"
                                       title="web实时通讯" target="_blank">web实时通讯</a>
                                    <span class="text-muted">Chen.H</span>
<a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a><a class="tag" taget="_blank" href="/search/%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">浏览器</a><a class="tag" taget="_blank" href="/search/socket/1.htm">socket</a><a class="tag" taget="_blank" href="/search/%E8%84%9A%E6%9C%AC/1.htm">脚本</a>
                                    <div>关于web实时通讯,做一些监控软件。 
由web服务器组件从消息服务器订阅实时数据,并建立消息服务器到所述web服务器之间的连接,web浏览器利用从所述web服务器下载到web页面的客户端代理与web服务器组件之间的socket连接,建立web浏览器与web服务器之间的持久连接;利用所述客户端代理与web浏览器页面之间的信息交互实现页面本地更新,建立一条从消息服务器到web浏览器页面之间的消息通路</div>
                                </li>
                                <li><a href="/article/2251.htm"
                                       title="[基因与生物]远古生物的基因可以嫁接到现代生物基因组中吗?" target="_blank">[基因与生物]远古生物的基因可以嫁接到现代生物基因组中吗?</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/%E7%94%9F%E7%89%A9/1.htm">生物</a>
                                    <div> 
 
      大家仅仅把我说的事情当作一个IT行业的笑话来听吧..没有其它更多的意思 
 
 
    如果我们把大自然看成是一位伟大的程序员,专门为地球上的生态系统编制基因代码,并创造出各种不同的生物来,那么6500万年前的程序员开发的代码,是否兼容现代派的程序员的代码和架构呢? 
 
  </div>
                                </li>
                                <li><a href="/article/2378.htm"
                                       title="oracle 外部表" target="_blank">oracle 外部表</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/%E5%A4%96%E9%83%A8%E8%A1%A8/1.htm">外部表</a><a class="tag" taget="_blank" href="/search/external+tables/1.htm">external tables</a>
                                    <div>    oracle外部表是只允许只读访问,不能进行DML操作,不能创建索引,可以对外部表进行的查询,连接,排序,创建视图和创建同义词操作。 
you can select, join, or sort external table data. You can also create views and synonyms for external tables. Ho</div>
                                </li>
                                <li><a href="/article/2505.htm"
                                       title="aop相关的概念及配置" target="_blank">aop相关的概念及配置</a>
                                    <span class="text-muted">daysinsun</span>
<a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a>
                                    <div>切面(Aspect): 
通常在目标方法执行前后需要执行的方法(如事务、日志、权限),这些方法我们封装到一个类里面,这个类就叫切面。 
 
 
连接点(joinpoint) 
spring里面的连接点指需要切入的方法,通常这个joinpoint可以作为一个参数传入到切面的方法里面(非常有用的一个东西)。 
 
 
通知(Advice) 
通知就是切面里面方法的具体实现,分为前置、后置、最终、异常环</div>
                                </li>
                                <li><a href="/article/2632.htm"
                                       title="初一上学期难记忆单词背诵第二课" target="_blank">初一上学期难记忆单词背诵第二课</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/english/1.htm">english</a><a class="tag" taget="_blank" href="/search/word/1.htm">word</a>
                                    <div>middle 中间的,中级的 
well 喔,那么;好吧 
phone 电话,电话机 
policeman 警察 
ask 问 
take 拿到;带到 
address 地址 
glad 高兴的,乐意的 
why 为什么  
China 中国 
family 家庭 
grandmother (外)祖母 
grandfather (外)祖父 
wife 妻子 
husband 丈夫 
da</div>
                                </li>
                                <li><a href="/article/2759.htm"
                                       title="Linux日志分析常用命令" target="_blank">Linux日志分析常用命令</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/log/1.htm">log</a>
                                    <div>1.查看文件内容 
cat 
-n 显示行号 2.分页显示 
more 
Enter 显示下一行 
空格 显示下一页 
F 显示下一屏 
B 显示上一屏 
less 
/get 查询"get"字符串并高亮显示 3.显示文件尾 
tail 
-f 不退出持续显示 
-n 显示文件最后n行 4.显示头文件 
head 
-n 显示文件开始n行 5.内容排序 
sort 
-n 按照</div>
                                </li>
                                <li><a href="/article/2886.htm"
                                       title="JSONP 原理分析" target="_blank">JSONP 原理分析</a>
                                    <span class="text-muted">fantasy2005</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/jsonp/1.htm">jsonp</a><a class="tag" taget="_blank" href="/search/jsonp+%E8%B7%A8%E5%9F%9F/1.htm">jsonp 跨域</a>
                                    <div>转自 http://www.nowamagic.net/librarys/veda/detail/224 
JavaScript是一种在Web开发中经常使用的前端动态脚本技术。在JavaScript中,有一个很重要的安全性限制,被称为“Same-Origin Policy”(同源策略)。这一策略对于JavaScript代码能够访问的页面内容做了很重要的限制,即JavaScript只能访问与包含它的</div>
                                </li>
                                <li><a href="/article/3013.htm"
                                       title="使用connect by进行级联查询" target="_blank">使用connect by进行级联查询</a>
                                    <span class="text-muted">234390216</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/%E6%9F%A5%E8%AF%A2/1.htm">查询</a><a class="tag" taget="_blank" href="/search/%E7%88%B6%E5%AD%90/1.htm">父子</a><a class="tag" taget="_blank" href="/search/Connect+by/1.htm">Connect by</a><a class="tag" taget="_blank" href="/search/%E7%BA%A7%E8%81%94/1.htm">级联</a>
                                    <div>使用connect by进行级联查询 
  
       connect by可以用于级联查询,常用于对具有树状结构的记录查询某一节点的所有子孙节点或所有祖辈节点。 
  
       来看一个示例,现假设我们拥有一个菜单表t_menu,其中只有三个字段:</div>
                                </li>
                                <li><a href="/article/3140.htm"
                                       title="一个不错的能将HTML表格导出为excel,pdf等的jquery插件" target="_blank">一个不错的能将HTML表格导出为excel,pdf等的jquery插件</a>
                                    <span class="text-muted">jackyrong</span>
<a class="tag" taget="_blank" href="/search/jquery%E6%8F%92%E4%BB%B6/1.htm">jquery插件</a>
                                    <div>发现一个老外写的不错的jquery插件,可以实现将HTML 
表格导出为excel,pdf等格式, 
地址在: 
https://github.com/kayalshri/ 
 
下面看个例子,实现导出表格到excel,pdf 
 
 


<html>
			<head>
				<title>Export html table to excel an</div>
                                </li>
                                <li><a href="/article/3267.htm"
                                       title="UI设计中我们为什么需要设计动效" target="_blank">UI设计中我们为什么需要设计动效</a>
                                    <span class="text-muted">lampcy</span>
<a class="tag" taget="_blank" href="/search/UI/1.htm">UI</a><a class="tag" taget="_blank" href="/search/UI%E8%AE%BE%E8%AE%A1/1.htm">UI设计</a>
                                    <div>关于Unity3D中的Shader的知识 
首先先解释下Unity3D的Shader,Unity里面的Shaders是使用一种叫ShaderLab的语言编写的,它同微软的FX文件或者NVIDIA的CgFX有些类似。传统意义上的vertex shader和pixel shader还是使用标准的Cg/HLSL 编程语言编写的。因此Unity文档里面的Shader,都是指用ShaderLab编写的代码,</div>
                                </li>
                                <li><a href="/article/3394.htm"
                                       title="如何禁止页面缓存" target="_blank">如何禁止页面缓存</a>
                                    <span class="text-muted">nannan408</span>
<a class="tag" taget="_blank" href="/search/html/1.htm">html</a><a class="tag" taget="_blank" href="/search/jsp/1.htm">jsp</a><a class="tag" taget="_blank" href="/search/cache/1.htm">cache</a>
                                    <div>禁止页面使用缓存~ 
------------------------------------------------ 
jsp:页面no cache: 
 
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cach</div>
                                </li>
                                <li><a href="/article/3521.htm"
                                       title="以代码的方式管理quartz定时任务的暂停、重启、删除、添加等" target="_blank">以代码的方式管理quartz定时任务的暂停、重启、删除、添加等</a>
                                    <span class="text-muted">Everyday都不同</span>
<a class="tag" taget="_blank" href="/search/%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86/1.htm">定时任务管理</a><a class="tag" taget="_blank" href="/search/spring-quartz/1.htm">spring-quartz</a>
                                    <div>      【前言】在项目的管理功能中,对定时任务的管理有时会很常见。因为我们不能指望只在配置文件中配置好定时任务就行了,因为如果要控制定时任务的 “暂停” 呢?暂停之后又要在某个时间点 “重启” 该定时任务呢?或者说直接 “删除” 该定时任务呢?要改变某定时任务的触发时间呢? “添加” 一个定时任务对于系统的使用者而言,是不太现实的,因为一个定时任务的处理逻辑他是不</div>
                                </li>
                                <li><a href="/article/3648.htm"
                                       title="EXT实例" target="_blank">EXT实例</a>
                                    <span class="text-muted">tntxia</span>
<a class="tag" taget="_blank" href="/search/ext/1.htm">ext</a>
                                    <div>  
(1) 增加一个按钮 
  
JSP: 
  
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
Stri</div>
                                </li>
                                <li><a href="/article/3775.htm"
                                       title="数学学习在计算机研究领域的作用和重要性" target="_blank">数学学习在计算机研究领域的作用和重要性</a>
                                    <span class="text-muted">xjnine</span>
<a class="tag" taget="_blank" href="/search/Math/1.htm">Math</a>
                                    <div>最近一直有师弟师妹和朋友问我数学和研究的关系,研一要去学什么数学课。毕竟在清华,衡量一个研究生最重要的指标之一就是paper,而没有数学,是肯定上不了世界顶级的期刊和会议的,这在计算机学界尤其重要!你会发现,不论哪个领域有价值的东西,都一定离不开数学!在这样一个信息时代,当google已经让世界没有秘密的时候,一种卓越的数学思维,绝对可以成为你的核心竞争力.  无奈本人实在见地</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>