Docker - 镜像 | 容器 日常开发常用指令 + 演示(一文通关)

目录

Docker 开发常用指令汇总

辅助命令

docker version

docker info

docker --help

镜像命令

查看镜像信息

下载镜像

搜索镜像

删除镜像

容器命令

查看运行中的容器

运行容器

停止、启动、重启、暂停、恢复容器

杀死容器

删除容器

查看容器日志

进入容器内部

容器与宿主机之间的文件拷贝

如何部署一个 web 项目(war 包项目)

查看容器内运行的进程信息

查看容器内部细节

容器数据卷机制

作用

注意

使用

容器打包镜像

背景

将容器打包成一个新的镜像

镜像的备份和恢复


Docker 开发常用指令汇总


辅助命令

docker version

用来查看 docker 客户端引擎 和 server 端引擎版本信息

[root@VM-8-17-centos ~]# docker version
Client: Docker Engine - CommunityVersion:           24.0.7API version:       1.43Go version:        go1.20.10Git commit:        afdd53bBuilt:             Thu Oct 26 09:11:35 2023OS/Arch:           linux/amd64Context:           defaultServer: Docker Engine - CommunityEngine:Version:          24.0.7API version:      1.43 (minimum version 1.12)Go version:       go1.20.10Git commit:       311b9ffBuilt:            Thu Oct 26 09:10:36 2023OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          1.6.24GitCommit:        61f9fd88f79f081d64d6fa3bb1a0dc71ec870523runc:Version:          1.1.9GitCommit:        v1.1.9-0-gccaecfcdocker-init:Version:          0.19.0GitCommit:        de40ad0

docker info

用来查看 docker 引擎详细信息

[root@VM-8-17-centos ~]# docker info
Client: Docker Engine - CommunityVersion:    24.0.7Context:    defaultDebug Mode: falsePlugins:buildx: Docker Buildx (Docker Inc.)Version:  v0.11.2Path:     /usr/libexec/docker/cli-plugins/docker-buildxcompose: Docker Compose (Docker Inc.)Version:  v2.21.0Path:     /usr/libexec/docker/cli-plugins/docker-composeServer:Containers: 4Running: 4Paused: 0Stopped: 0Images: 8Server Version: 24.0.7Storage Driver: overlay2Backing Filesystem: extfsSupports d_type: trueUsing metacopy: falseNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: cgroupfsCgroup Version: 1Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogSwarm: inactiveRuntimes: io.containerd.runc.v2 runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523runc version: v1.1.9-0-gccaecfcinit version: de40ad0Security Options:seccompProfile: builtinKernel Version: 3.10.0-1160.99.1.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 1.952GiBName: VM-8-17-centosID: 38c01492-c895-4bbc-8e2e-a575241b4201Docker Root Dir: /var/lib/dockerDebug Mode: falseExperimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://q9n10oke.mirror.aliyuncs.com/Live Restore Enabled: false

docker --help

用来查看帮助文档,给出了对于不同指令的解释

[root@VM-8-17-centos ~]# docker --helpUsage:  docker [OPTIONS] COMMANDA self-sufficient runtime for containersCommon Commands:run         Create and run a new container from an imageexec        Execute a command in a running containerps          List containersbuild       Build an image from a Dockerfilepull        Download an image from a registrypush        Upload an image to a registryimages      List imageslogin       Log in to a registrylogout      Log out from a registrysearch      Search Docker Hub for imagesversion     Show the Docker version informationinfo        Display system-wide informationManagement Commands:builder     Manage buildsbuildx*     Docker Buildx (Docker Inc., v0.11.2)compose*    Docker Compose (Docker Inc., v2.21.0)container   Manage containerscontext     Manage contextsimage       Manage imagesmanifest    Manage Docker image manifests and manifest listsnetwork     Manage networksplugin      Manage pluginssystem      Manage Dockertrust       Manage trust on Docker imagesvolume      Manage volumesSwarm Commands:swarm       Manage SwarmCommands:attach      Attach local standard input, output, and error streams to a running containercommit      Create a new image from a container's changescp          Copy files/folders between a container and the local filesystemcreate      Create a new containerdiff        Inspect changes to files or directories on a container's filesystemevents      Get real time events from the serverexport      Export a container's filesystem as a tar archivehistory     Show the history of an imageimport      Import the contents from a tarball to create a filesystem imageinspect     Return low-level information on Docker objectskill        Kill one or more running containersload        Load an image from a tar archive or STDINlogs        Fetch the logs of a containerpause       Pause all processes within one or more containersport        List port mappings or a specific mapping for the containerrename      Rename a containerrestart     Restart one or more containersrm          Remove one or more containersrmi         Remove one or more imagessave        Save one or more images to a tar archive (streamed to STDOUT by default)start       Start one or more stopped containersstats       Display a live stream of container(s) resource usage statisticsstop        Stop one or more running containerstag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop         Display the running processes of a containerunpause     Unpause all processes within one or more containersupdate      Update configuration of one or more containerswait        Block until one or more containers stop, then print their exit codesGlobal Options:--config string      Location of client config files (default "/root/.docker")-c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")-D, --debug              Enable debug mode-H, --host list          Daemon socket to connect to-l, --log-level string   Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")--tls                Use TLS; implied by --tlsverify--tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")--tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")--tlskey string      Path to TLS key file (default "/root/.docker/key.pem")--tlsverify          Use TLS and verify the remote-v, --version            Print version information and quitRun 'docker COMMAND --help' for more information on a command.For more help on how to use Docker, head to https://docs.docker.com/go/guides/

镜像命令

查看镜像信息

查看当前本地仓库中存在哪些镜像.

docker images -q | 镜像名
// -q 和 镜像名 是可选参数

a)docker images 就是 docker image ls 的缩写,用来镜像以及信息

[root@VM-8-17-centos ~]# docker images
REPOSITORY                  TAG              IMAGE ID       CREATED       SIZE
redis                       5                c5da061a611a   2 years ago   110MB
mysql                       5.7              c20987f18b13   2 years ago   448MB
rabbitmq                    3.8-management   699038cb2b96   2 years ago   250MB
nacos/nacos-server          1.4.2            938169b118c7   2 years ago   956MB
redis                       5.0.9            987b553c835f   3 years ago   98.3MB
bladex/sentinel-dashboard   1.8.0            61c10eaefbcf   3 years ago   147MB
nacos/nacos-server          1.2.0            763941e566bb   3 years ago   732MB
bladex/sentinel-dashboard   1.7.1            d12e18546bfd   3 years ago   148MB
  1. REPOSITORY:镜像名称
  2. TAG:版本
  3. IMAGE ID:镜像 id
  4. CREATED:镜像创建的时间(官方创建此镜像的时间)
  5. SIZE:镜像大小

b)docker images -q 是用来查看所有镜像 id 的

[root@VM-8-17-centos ~]# docker images -q
c5da061a611a
c20987f18b13
699038cb2b96
938169b118c7
987b553c835f
61c10eaefbcf
763941e566bb
d12e18546bfd

Ps:一个镜像的 id 是很长的,这里只会展示一个部分

c)docker images 镜像名 用来查看指定镜像信息(镜像名相同,版本不同)

[root@VM-8-17-centos ~]# docker images redis
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
redis        5         c5da061a611a   2 years ago   110MB
redis        5.0.9     987b553c835f   3 years ago   98.3MB

同理,docker images -q 镜像名 就是展示指定镜像名的镜像id.

[root@VM-8-17-centos ~]# docker images -q redis
c5da061a611a
987b553c835f

下载镜像

用来下载一个镜像

docker pull 镜像名:版本号

a)例如下载最新版本 redis:docker pull redis 等同于 docker pull redis:latest

b)例如下载指定版本 redis:docker pull redis:5.0.9

搜索镜像

搜索镜像,只能查看远端仓库是否存在该镜像,不能列出版本.

docker search 镜像名

a)例如查看 tomcat 镜像是否存在

[root@VM-8-17-centos ~]# docker search tomcat
NAME                                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tomcat                                Apache Tomcat is an open source implementati…   3618      [OK]       
tomee                                 Apache TomEE is an all-Apache Java EE certif…   113       [OK]       
bitnami/tomcat                        Bitnami Tomcat Docker Image                     51                   [OK]
bitnamicharts/tomcat                                                                  0                    
secoresearch/tomcat-varnish           Tomcat and Varnish 5.0                          0                    [OK]
vulhub/tomcat                                                                         0                    
islandora/tomcat                                                                      0                    
wnprcehr/tomcat                                                                       0                    
jumpserver/tomcat                     Apache Tomcat is an open source implementati…   0                    
hivdb/tomcat-with-nucamino                                                            0                    
sismics/tomcat                        Apache Tomcat Servlet Container                 1                    
eclipse/rdf4j-workbench               Dockerfile for Eclipse RDF4J Server and Work…   6                    
eclipse/hadoop-dev                    Ubuntu 14.04, Maven 3.3.9, JDK8, Tomcat 8       0                    [OK]
gbif/ipt                              The GBIF Integrated Publishing Toolkit (IPT)…   2                    
dhis2/base-dev                        Images in this repository contains DHIS2 WAR…   0                    
eclipse/alpine_jdk8                   Based on Alpine 3.3. JDK 1.8, Maven 3.3.9, T…   1                    [OK]
dhis2/base                            Images in this repository contains DHIS2 WAR…   0                    
jelastic/tomcat                       An image of the Tomcat Java application serv…   4                    
cfje/tomcat-resource                  Tomcat Concourse Resource                       2                    
rightctrl/tomcat                      CentOS , Oracle Java, tomcat application ssl…   7                    [OK]
amd64/tomcat                          Apache Tomcat is an open source implementati…   8                    
arm64v8/tomcat                        Apache Tomcat is an open source implementati…   9                    
tomcat2111/papercut-mf                PaperCut MF Application Server                  0                    
softwareplant/tomcat                  Tomcat images for jira-cloud testing            0                    [OK]
tomcatengineering/pg_backup_rotated   Clone of martianrock/pg_backup_rotated but w…   0                    

删除镜像

删除指定镜像

docker image rm 镜像名(name:tag) | 镜像id

a)正常删除(要求:必须是没有正在运行的镜像),例如删除 tomcat:8.0 镜像

[root@VM-8-17-centos ~]# docker image rm tomcat:8.0
Untagged: tomcat:8.0
Untagged: tomcat@sha256:8ecb10948deb32c34aeadf7bf95d12a93fbd3527911fa629c1a3e7823b89ce6f
Deleted: sha256:ef6a7c98d192507d6066dcf24e44bec66d07ec9cf7c55d8d3d1ea0a24660bdef
Deleted: sha256:6dc5bbd9ede58ce52f6e9d34eaac4e3bf1fbb3014e9eae344677bf3c2f022a17
Deleted: sha256:6f22c12dcf0ac783b0b00471e38262c708761a677e6a847a57a5d7cce2cbc7f1
Deleted: sha256:dbefc7cd29b21d99c136d6234ca442cdb89fc91f3c91ef6c1d333d37424d2f44
Deleted: sha256:d65396dbf112285c9d395bb33c2eb2f776cd9b959c007152c10a2f25fbf1c198
Deleted: sha256:5b8a875f80bdd2e9f9cf2c0852243e0cb59ea7be5e92620b2c2089800bb18594
Deleted: sha256:d97b31b9ca51e024a895e2f6fa032224fb73ba2a070149499ce87306ed9d7af6
Deleted: sha256:3717c4f05493340d97d982bc6ed8cba98869833918de23c78c39414788dd08c1
Deleted: sha256:b9c326fb510188d2958888aee970ae93925c2a2ad8a78b2ec3a521747ee3ec4f
Deleted: sha256:8cc193ff8a5b4837eab54bee27418daadad8825f13b8fab55229b4954fee6f9f
Deleted: sha256:b1852f6f3f85863ed849af673e566ad8de76dac4d2c6526d791e965978c1ce62
Deleted: sha256:8c466bf4ca6ffdda8b7717b1cd6fe31109529ee64e626a003a224fb8bd2bc469

b)强制删除(可以删除正在运行的镜像):docker image rm -f 镜像名(name:tag) | 镜像 id

c)批量删除,例如删除所有 tomcat 镜像:docker image rm -f $(docker image tomcat -q)

容器命令

查看运行中的容器

查看运行中的容器信息

docker ps -a | -q

a)查看当前 docker 引擎中正在运行的容器

[root@VM-8-17-centos ~]# docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED       STATUS       PORTS                                                                                                                                                 NAMES
abc6284fe34d   redis:5.0.9                "docker-entrypoint.s…"   5 weeks ago   Up 5 weeks   0.0.0.0:6380->6379/tcp, :::6380->6379/tcp                                                                                                             redis
d442ff7829df   nacos/nacos-server:1.4.2   "bin/docker-startup.…"   6 weeks ago   Up 5 weeks   0.0.0.0:8848->8848/tcp, :::8848->8848/tcp                                                                                                             nacos
fc16ae62dc0f   mysql:5.7                  "docker-entrypoint.s…"   7 weeks ago   Up 7 weeks   33060/tcp, 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp                                                                                                  mysql
a7dbf979b1e6   rabbitmq:3.8-management    "docker-entrypoint.s…"   7 weeks ago   Up 7 weeks   4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp   mq
  • CONTAINER ID:容器 id
  • IMAGE:基于那个镜像运行的
  • COMMAND:容器内启动服务的命令
  • CREATED:容器创建时间
  • STATUS:容器状态
  • PORTS:容器服务监听端口("->" 前表示宿主机端口,"->" 后表示映射的容器端口)
  • NAMES:容器名称(启动时,通过 --name 参数自定义的)

b)查看所有容器(运行 和 停止 的容器):docker ps -a

c)查看所有容器id:docker ps -aq

运行容器

docker run -d(后台运行) -p(端口映射) --name 自定义容器名 镜像名:tag

以下拿 tomcat:8.0 来举例 

a)简单运行一个容器(这种方式运行容器,会导致容器内无法访问,因为这里涉及到容器端口映射的概念,后面会讲)

[root@VM-8-17-centos ~]# docker run tomcat:8.0
23-Dec-2023 12:25:27.847 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.53
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 29 2018 14:42:45 UTC
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.53.0
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.10.0-1160.99.1.el7.x86_64
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-7-openjdk-amd64/jre
23-Dec-2023 12:25:27.849 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_181-b01
23-Dec-2023 12:25:27.850 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
23-Dec-2023 12:25:27.850 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
23-Dec-2023 12:25:27.850 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
23-Dec-2023 12:25:27.851 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
23-Dec-2023 12:25:27.852 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.17 using APR version 1.5.1.
23-Dec-2023 12:25:27.852 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
23-Dec-2023 12:25:27.855 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0f  25 May 2017)
23-Dec-2023 12:25:28.071 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
23-Dec-2023 12:25:28.083 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
23-Dec-2023 12:25:28.086 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 951 ms
23-Dec-2023 12:25:28.147 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
23-Dec-2023 12:25:28.148 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.53
23-Dec-2023 12:25:28.163 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
23-Dec-2023 12:25:28.827 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 663 ms
23-Dec-2023 12:25:28.827 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
23-Dec-2023 12:25:29.319 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 492 ms
23-Dec-2023 12:25:29.319 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
23-Dec-2023 12:25:29.379 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 60 ms
23-Dec-2023 12:25:29.379 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
23-Dec-2023 12:25:29.439 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 60 ms
23-Dec-2023 12:25:29.439 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
23-Dec-2023 12:25:29.468 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 29 ms
23-Dec-2023 12:25:29.486 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
23-Dec-2023 12:25:29.550 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
23-Dec-2023 12:25:29.554 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1467 ms

b)运行 tomcat 容器,设置容器与宿主机端口映射关系

docker run -p 8081:8080 tomcat:8.0

Ps:-p 8081(宿主机):8080(容器)

c)运行 tomcat 容器,设置设置容器与宿主机端口映射关系,后台启动服务

docker run -p 8081:8080 -d tomcat:8.0

d)运行 tomcat 容器,设置设置容器与宿主机端口映射关系,后台启动服务,自定义容器名称

docker run -p 8081:8080 -d --name tomcat_1 tomcat:8.0

停止、启动、重启、暂停、恢复容器

停止容器:docker stop 容器id | name(这里的 name 是启动时自定义的)

启动容器:docker start 容器 id | name

重启容器:docker restart 容器 id | name

暂停容器:docker pause 容器 id | name

恢复容器(从暂停恢复到启动):docker unpause 容器 id | name

杀死容器

docker kill id | name

例如删除名称为 tomcat_1 的容器 

[root@VM-8-17-centos ~]# docker kill tomcat_1
tomcat_1

删除容器

a)正常删除容器(只能删除已经停止的容器):docker rm id | name

b)强制删除容器(可以删除运行中的容器):docker rm -f id | name

c)批量删除容器:docker rm -f $(docker ps -qa)

查看容器日志

docker logs -f id | name

a)查看当前容器的日志信息,例如查看 tomcat_1 容器的日志

[root@VM-8-17-centos ~]# docker logs tomcat_1
23-Dec-2023 12:50:00.505 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.53
23-Dec-2023 12:50:00.508 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 29 2018 14:42:45 UTC
23-Dec-2023 12:50:00.508 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.53.0
23-Dec-2023 12:50:00.508 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
23-Dec-2023 12:50:00.508 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.10.0-1160.99.1.el7.x86_64
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-7-openjdk-amd64/jre
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_181-b01
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
23-Dec-2023 12:50:00.509 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
23-Dec-2023 12:50:00.510 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
23-Dec-2023 12:50:00.511 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.17 using APR version 1.5.1.
23-Dec-2023 12:50:00.511 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
23-Dec-2023 12:50:00.515 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0f  25 May 2017)
23-Dec-2023 12:50:00.712 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
23-Dec-2023 12:50:00.724 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
23-Dec-2023 12:50:00.726 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 920 ms
23-Dec-2023 12:50:00.780 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
23-Dec-2023 12:50:00.780 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.53
23-Dec-2023 12:50:00.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
23-Dec-2023 12:50:01.435 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 639 ms
23-Dec-2023 12:50:01.435 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
23-Dec-2023 12:50:01.931 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 496 ms
23-Dec-2023 12:50:01.931 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
23-Dec-2023 12:50:02.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 70 ms
23-Dec-2023 12:50:02.002 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
23-Dec-2023 12:50:02.075 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 73 ms
23-Dec-2023 12:50:02.075 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
23-Dec-2023 12:50:02.108 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 33 ms
23-Dec-2023 12:50:02.118 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
23-Dec-2023 12:50:02.152 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
23-Dec-2023 12:50:02.155 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1429 ms

b)通过 -f 实时监控容器内服务的日志:docker logs -f id | name

进入容器内部

docker exec -it(交互模式) id | name bash

a)例如进入 tomcat_1 容器内部,然后查看容器内部的文件

[root@VM-8-17-centos ~]# docker exec -it tomcat_1 bash
root@e823da882acc:/usr/local/tomcat# ls
LICENSE  NOTICE  RELEASE-NOTES	RUNNING.txt  bin  conf	include  lib  logs  native-jni-lib  temp  webapps  work

b)退出容器:exit

root@e823da882acc:/usr/local/tomcat# exit
exit
[root@VM-8-17-centos ~]# 

容器与宿主机之间的文件拷贝

a)将容器中指定文件拷贝到宿主机:docker cp 容器id:容器中文件或目录 宿主机目录

例如将 tomcat 容器中的 /usr/local/tomcat/RUNNING.txt 文件拷贝到宿主机的 /root/cyk/ 目录下

[root@VM-8-17-centos cyk]# docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS                                                                                                                                                 NAMES
e823da882acc   tomcat:8.0                 "catalina.sh run"        11 minutes ago   Up 11 minutes   0.0.0.0:8082->8080/tcp, :::8082->8080/tcp                                                                                                             tomcat_1
abc6284fe34d   redis:5.0.9                "docker-entrypoint.s…"   5 weeks ago      Up 5 weeks      0.0.0.0:6380->6379/tcp, :::6380->6379/tcp                                                                                                             redis
d442ff7829df   nacos/nacos-server:1.4.2   "bin/docker-startup.…"   6 weeks ago      Up 5 weeks      0.0.0.0:8848->8848/tcp, :::8848->8848/tcp                                                                                                             nacos
fc16ae62dc0f   mysql:5.7                  "docker-entrypoint.s…"   7 weeks ago      Up 7 weeks      33060/tcp, 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp                                                                                                  mysql
a7dbf979b1e6   rabbitmq:3.8-management    "docker-entrypoint.s…"   7 weeks ago      Up 7 weeks      4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp   mq
[root@VM-8-17-centos cyk]# 
[root@VM-8-17-centos cyk]# docker cp e8:/usr/local/tomcat/RUNNING.txt /root/cyk/
Successfully copied 17.9kB to /root/cyk/
[root@VM-8-17-centos cyk]# ls
RUNNING.txt

Ps:这里的 e8 是 tomcat_1 容器 id 的简写,只要能区分开,怎么简写都可以

b)将宿主机中指定文件拷贝到容器内:docker cp 宿主机目录 容器id:容器中文件或目录

如何部署一个 web 项目(war 包项目)

a)将 xxx.war 上传到 linux 服务器

b)通过 docker cp 命令将 xxx.war 赋值到 tomcat 的 webapp 目录中即可.

c)使用 ip 端口进行测试访问即可.

查看容器内运行的进程信息

docker top 容器id | name

a)查看 tomcat_1 容器内运行的进程信息

[root@VM-8-17-centos cyk]# docker top tomcat_1
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                32112               32092               0                   20:49               ?                   00:00:05            /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start

查看容器内部细节

docker inspect 容器id | name

a)例如查看 tomcat_1 容器内部细节 

[root@VM-8-17-centos cyk]# docker inspect tomcat_1
[{"Id": "e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665","Created": "2023-12-23T12:49:58.845311366Z","Path": "catalina.sh","Args": ["run"],"State": {"Status": "running","Running": true,"Paused": false,"Restarting": false,"OOMKilled": false,"Dead": false,"Pid": 32112,"ExitCode": 0,"Error": "","StartedAt": "2023-12-23T12:49:59.234928823Z","FinishedAt": "0001-01-01T00:00:00Z"},"Image": "sha256:ef6a7c98d192507d6066dcf24e44bec66d07ec9cf7c55d8d3d1ea0a24660bdef","ResolvConfPath": "/var/lib/docker/containers/e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665/resolv.conf","HostnamePath": "/var/lib/docker/containers/e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665/hostname","HostsPath": "/var/lib/docker/containers/e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665/hosts","LogPath": "/var/lib/docker/containers/e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665/e823da882accc99496e297da6cbf0004e3b1033304f65d6a2d3e538a36d53665-json.log","Name": "/tomcat_1","RestartCount": 0,"Driver": "overlay2","Platform": "linux","MountLabel": "","ProcessLabel": "","AppArmorProfile": "","ExecIDs": null,"HostConfig": {"Binds": null,"ContainerIDFile": "","LogConfig": {"Type": "json-file","Config": {}},"NetworkMode": "default","PortBindings": {"8080/tcp": [{"HostIp": "","HostPort": "8082"}]},"RestartPolicy": {"Name": "no","MaximumRetryCount": 0},"AutoRemove": false,"VolumeDriver": "","VolumesFrom": null,"ConsoleSize": [36,171],"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","Isolation": "","CpuShares": 0,"Memory": 0,"NanoCpus": 0,"CgroupParent": "","BlkioWeight": 0,"BlkioWeightDevice": [],"BlkioDeviceReadBps": [],"BlkioDeviceWriteBps": [],"BlkioDeviceReadIOps": [],"BlkioDeviceWriteIOps": [],"CpuPeriod": 0,"CpuQuota": 0,"CpuRealtimePeriod": 0,"CpuRealtimeRuntime": 0,"CpusetCpus": "","CpusetMems": "","Devices": [],"DeviceCgroupRules": null,"DeviceRequests": null,"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","/sys/devices/virtual/powercap"],"ReadonlyPaths": ["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"GraphDriver": {"Data": {"LowerDir": "/var/lib/docker/overlay2/1807f8589086eb51f861c4938ddbd1da9395c48ef3b1bc40ded35195707c07db-init/diff:/var/lib/docker/overlay2/4272a408897873c3e991cc410cc9f3191dc2ebb5a8f940e386746a8b62e45b77/diff:/var/lib/docker/overlay2/aefe736cf7883ec152540cf245eebf8d1daee7ebd7752db0f2aed440db9c436e/diff:/var/lib/docker/overlay2/eab8218d1796d5eaa07da26ded1c78c01b0d7dfaf96654c7223f94fa022804ca/diff:/var/lib/docker/overlay2/6a1ae79728973f2f3dde69c44b8bf36c7e3e8dee18a67777f2c18298c27b72e3/diff:/var/lib/docker/overlay2/4284addc9df80d1ca1f05dddd850dd749c9cc55c34f28b0876d5eaacc2d576e5/diff:/var/lib/docker/overlay2/ed77212064855a9fee7e0403c15a23667de8c08fe7d59635f328c1b91e8e0af1/diff:/var/lib/docker/overlay2/1e0a0cebf48bf83030ebecda040939bc9eb11094883fa716bde5789cfc8d5ed1/diff:/var/lib/docker/overlay2/648a8998071f0296333f194e322e6785fb01b763e684543c6d665eb74965567b/diff:/var/lib/docker/overlay2/96aaa73c0076e21994ad88907d5f425ebf630fab7e091eb301073b4429c2f609/diff:/var/lib/docker/overlay2/6315239813db62569e9e729bbf20f7d6220df8a170fbd4fae2e1eba015e4f51d/diff:/var/lib/docker/overlay2/6951fbc42d9b579b84c403fdb31421d105aac328ad81e2e3e1d55a11556afcf7/diff","MergedDir": "/var/lib/docker/overlay2/1807f8589086eb51f861c4938ddbd1da9395c48ef3b1bc40ded35195707c07db/merged","UpperDir": "/var/lib/docker/overlay2/1807f8589086eb51f861c4938ddbd1da9395c48ef3b1bc40ded35195707c07db/diff","WorkDir": "/var/lib/docker/overlay2/1807f8589086eb51f861c4938ddbd1da9395c48ef3b1bc40ded35195707c07db/work"},"Name": "overlay2"},"Mounts": [],"Config": {"Hostname": "e823da882acc","Domainname": "","User": "","AttachStdin": false,"AttachStdout": false,"AttachStderr": false,"ExposedPorts": {"8080/tcp": {}},"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": ["PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","LANG=C.UTF-8","JAVA_HOME=/docker-java-home/jre","JAVA_VERSION=7u181","JAVA_DEBIAN_VERSION=7u181-2.6.14-1~deb8u1","CATALINA_HOME=/usr/local/tomcat","TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib","LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib","OPENSSL_VERSION=1.1.0f-3+deb9u2","GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23","TOMCAT_MAJOR=8","TOMCAT_VERSION=8.0.53","TOMCAT_SHA512=cd8a4e48a629a2f2bb4ce6b101ebcce41da52b506064396ec1b2915c0b0d8d82123091242f2929a649bcd8b65ecf6cd1ab9c7d90ac0e261821097ab6fbe22df9","TOMCAT_TGZ_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz \thttps://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz \thttps://www.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz \thttps://archive.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz","TOMCAT_ASC_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz.asc \thttps://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz.asc \thttps://www.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz.asc \thttps://archive.apache.org/dist/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz.asc"],"Cmd": ["catalina.sh","run"],"Image": "tomcat:8.0","Volumes": null,"WorkingDir": "/usr/local/tomcat","Entrypoint": null,"OnBuild": null,"Labels": {}},"NetworkSettings": {"Bridge": "","SandboxID": "7c5c3740d5acbd7748c07d0203d0833f72ebb617c7b3d0e76a3e6d8a2510e062","HairpinMode": false,"LinkLocalIPv6Address": "","LinkLocalIPv6PrefixLen": 0,"Ports": {"8080/tcp": [{"HostIp": "0.0.0.0","HostPort": "8082"},{"HostIp": "::","HostPort": "8082"}]},"SandboxKey": "/var/run/docker/netns/7c5c3740d5ac","SecondaryIPAddresses": null,"SecondaryIPv6Addresses": null,"EndpointID": "2294463d89e7a91ee32cbd717403ceb9d1079fc23fca9cd251c003fa019bff0c","Gateway": "172.17.0.1","GlobalIPv6Address": "","GlobalIPv6PrefixLen": 0,"IPAddress": "172.17.0.6","IPPrefixLen": 16,"IPv6Gateway": "","MacAddress": "02:42:ac:11:00:06","Networks": {"bridge": {"IPAMConfig": null,"Links": null,"Aliases": null,"NetworkID": "3be1ce6eea6f4f139c964c6afa94dd46fa60576e291edbc56d730c3c977b018c","EndpointID": "2294463d89e7a91ee32cbd717403ceb9d1079fc23fca9cd251c003fa019bff0c","Gateway": "172.17.0.1","IPAddress": "172.17.0.6","IPPrefixLen": 16,"IPv6Gateway": "","GlobalIPv6Address": "","GlobalIPv6PrefixLen": 0,"MacAddress": "02:42:ac:11:00:06","DriverOpts": null}}}}
]

容器数据卷机制

作用

a)主要作用:

用来实现容器中数据和宿主机中数据进行映射的(这里可以类比 Vue 中的双向绑定,修改任意一方,另一方都会跟着修改)

b)使用场景:

  1. 易修改:即使我们不进入容器的内部,也可以通过修改宿主机文件系统的 conf 文件,来修改容器中的 conf 文件;
  2. 数据可复用:当创建了新的容器并且需要复用之前的 conf 文件时,可以直接再创建一个数据卷或者修改之前数据卷对容器目录的指向即可,来进行关联,这样就可以将之前的配置映射到新容器的配置中;
  3. 升级维护简单:如果来了新的容器,需要删除旧容器,也不用担心数据会被删除掉,因为数据在宿主机上还保存了一份。
     

注意

数据卷只能在容器首次启动时设置.

使用

容器首次启动时指定 -v 参数

a)使用绝对路径设置数据卷

docker run -v 宿主机绝对路径:容器内绝对路径:ro .....(其他设置)

ro:表示 ready only,也就是只读的意思,如果在设置数据卷时指定 ro,代表日后从容器内访问该路径时是只读的.

Ps:这种方式会将容器该路径下的原始内容全部清空,始终以宿主机路径为主.

b)使用别名方式设置数据卷

docker run -v aa:/usr/local/tomcat/webapps ......(其他配置)

aa:

  1. aa 代表 docker 数据卷中别名. (如果存在就直接使用,不存在就创建)
  2. 使用别名方式保留容器路径原始内容,前提是别名对应路径不能存在内容.

Ps:docker 根据别名创建目录默认在 /var/lib/docker/volumes/ 中.

通过 find 命令也可以查找到该路径

 

容器打包镜像

背景

a)回顾三个核心概念

仓库 repository:docker 官方维护的一个仓库,用来集中存储镜像.

镜像 image:一个镜像代表一个软件服务,特点就是 "只读".

容器 container:镜像每运行一次形成一个容器,运行的容器代表一个正在运行的软件服务.

b)为什么要将容器打包成一个新的镜像?

容器可读可写,那么基于这个特性就可以对容器进行自己的深度定制.

将容器打包成一个新的镜像,日后运行的这个容器就存在原始定制的特性.

c)原理图

将容器打包成一个新的镜像

docker commit -m "对镜像的描述" -a "作者名称" 容器id | name  镜像名:版本

如下案例

[root@VM-8-17-centos cyk]# docker ps -a
CONTAINER ID   IMAGE                      COMMAND                  CREATED             STATUS                           PORTS                                                                                                                                                 NAMES
e823da882acc   tomcat:8.0                 "catalina.sh run"        About an hour ago   Up About an hour                 0.0.0.0:8082->8080/tcp, :::8082->8080/tcp                                                                                                             tomcat_1
07a1f69b4c4c   tomcat:8.0                 "catalina.sh run"        About an hour ago   Exited (137) About an hour ago                                                                                                                                                         objective_taussig
abc6284fe34d   redis:5.0.9                "docker-entrypoint.s…"   5 weeks ago         Up 5 weeks                       0.0.0.0:6380->6379/tcp, :::6380->6379/tcp                                                                                                             redis
d442ff7829df   nacos/nacos-server:1.4.2   "bin/docker-startup.…"   6 weeks ago         Up 5 weeks                       0.0.0.0:8848->8848/tcp, :::8848->8848/tcp                                                                                                             nacos
fc16ae62dc0f   mysql:5.7                  "docker-entrypoint.s…"   7 weeks ago         Up 7 weeks                       33060/tcp, 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp                                                                                                  mysql
a7dbf979b1e6   rabbitmq:3.8-management    "docker-entrypoint.s…"   7 weeks ago         Up 7 weeks                       4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp   mq
[root@VM-8-17-centos cyk]# 
[root@VM-8-17-centos cyk]# 
[root@VM-8-17-centos cyk]# 
[root@VM-8-17-centos cyk]# docker commit -m "new test tomcat" -a "cyk" e8 tomcat_cyk:8.1
sha256:9b9add65a1f1b2a9331bac5f0c047af6a921e0850b247638256843a770b4ed6d
[root@VM-8-17-centos cyk]# docker images
REPOSITORY                  TAG              IMAGE ID       CREATED          SIZE
tomcat_cyk                  8.1              9b9add65a1f1   10 seconds ago   356MB
redis                       5                c5da061a611a   2 years ago      110MB
mysql                       5.7              c20987f18b13   2 years ago      448MB
rabbitmq                    3.8-management   699038cb2b96   2 years ago      250MB
nacos/nacos-server          1.4.2            938169b118c7   2 years ago      956MB
redis                       5.0.9            987b553c835f   3 years ago      98.3MB
bladex/sentinel-dashboard   1.8.0            61c10eaefbcf   3 years ago      147MB
nacos/nacos-server          1.2.0            763941e566bb   3 years ago      732MB
bladex/sentinel-dashboard   1.7.1            d12e18546bfd   3 years ago      148MB
tomcat                      8.0              ef6a7c98d192   5 years ago      356MB

镜像的备份和恢复

a)备份镜像: docker save 镜像名:tag -o (镜像名-tag).tar

b)恢复镜像:docker load -i xxx.tar

例如 docker load -i tomcat-8.0.tar 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/223392.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux创建macvlan 测试bridge、private和vepa模式

Linux创建macvlan,测试bridge、private和vepa模式 最近在看Docker的网络,看到关于macvlan网络的介绍。查阅了相关资料,记录如下。 参考 1.Linux Macvlan 2.图解几个与Linux网络虚拟化相关的虚拟网卡-VETH/MACVLAN/MACVTAP/IPVLAN 环境 操…

谷粒商城-商品服务-新增商品功能开发(商品图片无法展示问题没有解决)

在网关配置路由 - id: member_routeuri: lb://gulimemberpredicates:- Path/api/gulimember/**filters:- RewritePath/api/(?<segment>.*),/$\{segment}并将所有逆向生成的工程调式出来 获取分类关联的品牌 例如&#xff1a;手机&#xff08;分类&#xff09;-> 品…

采用SpringBoot框架+原生HTML、JS前后端分离模式开发和部署的电子病历编辑器源码(电子病历评级4级)

概述&#xff1a; 电子病历是指医务人员在医疗活动过程中,使用医疗机构信息系统生成的文字、符号、图表、图形、数据、影像等数字化信息,并能实现存储、管理、传输和重现的医疗记录,是病历的一种记录形式。 医院通过电子病历以电子化方式记录患者就诊的信息&#xff0c;包括&…

【智慧办公】如何让智能会议室的电子标签实现远程、批量更新信息?东胜物联网硬件网关让解决方案更具竞争力

近年来&#xff0c;为了减少办公耗能、节能环保、降本增效&#xff0c;越来越多的企业开始从传统的办公模式转向智慧办公。 以智能会议室为例&#xff0c;会议是企业业务中不可或缺的一部分&#xff0c;但在传统办公模式下&#xff0c;一来会议前行政人员需要提前准备会议材料…

助力打造清洁环境,基于YOLOv4开发构建公共场景下垃圾堆放垃圾桶溢出检测识别系统

公共社区环境生活垃圾基本上是我们每个人每天几乎都无法避免的一个问题&#xff0c;公共环境下垃圾投放点都会有固定的值班时间&#xff0c;但是考虑到实际扔垃圾的无规律性&#xff0c;往往会出现在无人值守的时段内垃圾堆放垃圾桶溢出等问题&#xff0c;有些容易扩散的垃圾比…

【数据结构入门精讲 | 第十篇】考研408排序算法专项练习(二)

在上文中我们进行了排序算法的判断题、选择题的专项练习&#xff0c;在这一篇中我们将进行排序算法中编程题的练习。 目录 编程题R7-1 字符串的冒泡排序R7-1 抢红包R7-1 PAT排名汇总R7-2 统计工龄R7-1 插入排序还是堆排序R7-2 龙龙送外卖R7-3 家谱处理 编程题 R7-1 字符串的冒…

SpringSecurity深度解析与实践(3)

这里写自定义目录标题 引言SpringSecurity之授权授权介绍java权限集成 登录失败三次用户上锁 引言 SpringSecurity深度解析与实践&#xff08;2&#xff09;的网址 SpringSecurity之授权 授权介绍 Spring Security 中的授权分为两种类型&#xff1a; 基于角色的授权&#…

LV.13 D6 Linux内核安装及交叉编译 学习笔记

一、tftp加载Linux内核及rootfs 1.1 uboot内核启动命令 bootm 启动指定内存地址上的Linux内核并为内核传递参数 bootm kernel-addr ramdisk-addr dtb-addr 注: kernel-addr: 内核的下载地址 ramdisk-addr: 根文件系统的下载地址 …

.Net 访问电子邮箱-LumiSoft.Net,好用

序言&#xff1a; 网上找了很多关于.Net如何访问电子邮箱的方法&#xff0c;但是大多数都达不到想要的需求&#xff0c;只有一些 收发邮件。因此 花了很大功夫去看 LumiSoft.Net.dll 的源码&#xff0c;总算做出自己想要的结果了&#xff0c;果然学习诗人进步。 介绍&#xff…

使用@jiaminghi/data-view实现一个数据大屏

<template><div class"content bg"><!-- 全局容器 --><!-- <dv-full-screen-container> --><!-- 第二行 --><div class"module-box" style"align-items: start; margin-top: 10px"><!-- 左 -->…

redis基本用法学习(C#调用CSRedisCore操作redis)

除了NRedisStack包&#xff0c;csredis也是常用的redis操作模块&#xff08;从EasyCaching提供的常用redis操作包来看&#xff0c;CSRedis、freeredis、StackExchange.Redis应该都属于常用redis操作模块&#xff09;&#xff0c;本文学习使用C#调用CSRedis包操作redis的基本方式…

C# WPF上位机开发(从demo编写到项目开发)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 C# WPF编程&#xff0c;特别是控件部分&#xff0c;其实学起来特别快。只是后面多了多线程、锁、数据库、网络这部分稍微复杂一点&#xff0c;不过…

交通流预测 | Matlab基于KNN-BiLSTM的交通流预测(对比SVR、LSTM、GRU、KNN-LSTM)

目录 预测效果基本介绍程序设计参考资料 预测效果 基本介绍 交通流预测 | Matlab基于KNN-BiLSTM的交通流预测&#xff08;对比SVR、LSTM、GRU、KNN-LSTM&#xff09; 程序设计 完整程序和数据获取方式&#xff1a;私信博主回复Matlab基于KNN-BiLSTM的交通流预测&#xff08;对…

oracle即时客户端(Instant Client)安装与配置

之前的文章记录了oracle客户端和服务端的下载与安装&#xff0c;内容参见&#xff1a; 在Windows中安装Oracle_windows安装oracle 如果不想安装oracle客户端&#xff08;或者是电脑因为某些原因无法安装oracle客户端&#xff09;&#xff0c;还想能够连接oracle远程服务&#…

网络安全行业术语

病毒 是在计算机程序中插入的破坏计算机功能或者数据的代码&#xff0c;能影响计算机使用&#xff0c;能自我复制的一组计算机指令或者程序代码。 抓鸡 利用使用大量的程序的漏洞&#xff0c;使用自动化方式获取肉鸡的行为&#xff0c;即设法控制电脑&#xff0c;将其沦为肉…

【银行测试】银行金融测试+金融项目测试点汇总...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 1、银行金融测试是…

OpenCV | 霍夫变换:以车道线检测为例

霍夫变换 霍夫变换只能灰度图&#xff0c;彩色图会报错 lines cv2.HoughLinesP(edge_img,1,np.pi/180,15,minLineLength40,maxLineGap20) 参数1&#xff1a;要检测的图片矩阵参数2&#xff1a;距离r的精度&#xff0c;值越大&#xff0c;考虑越多的线参数3&#xff1a;距离…

制造行业定制软件解决方案——工业信息采集平台

摘要&#xff1a;针对目前企业在线检测数据信号种类繁多&#xff0c;缺乏统一监控人员和及时处置措施等问题。蓝鹏测控开发针对企业工业生产的在线数据的集中采集分析平台&#xff0c;通过该工业信息采集平台可将企业日常各种仪表设备能够得到数据进行集中分析处理存储&#xf…

操作系统 day17(读者-写者问题、哲学家进餐问题)

读者-写者问题 分析 读者优先的代码实现 若不对count采用互斥操作&#xff0c;那么会导致读者进程之间存在&#xff1a;某个读者进程阻塞在P(rw)中&#xff0c;且它需要等到最后一个读者进程解锁V(rw)才能被唤醒&#xff0c;这很影响系统效率&#xff0c;如果我们对count进行…

STM32软硬件CRC测速对比

硬件CRC配置 以及软硬件CRC速度对比 使用CUBEMX配置默认使用的是CRC32&#xff0c;从库中可以看出这一点 HAL库提供了以下两个计算函数 HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 这个函数用于在已有的CRC校验结果的基础上累积…