docker

1.安装docker

1.连接虚拟机,环境查看:

uname -r

2.查看系统配置:

cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

.安装步骤

1.卸载旧的版本

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

在这里插入图片描述
2.需要的安装包。

yum install -y yum-utils

3.设置镜像仓库

yum-config-manager \
         --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #推荐使用阿里云
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210314113447144.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0OTI2NTcx,size_16,color_FFFFFF,t_70)

4.更新yum索引

yum makecache fast

5.安装docker引擎

yum install docker-ce docker-ce-cli containerd.io

6.启动docker

systemctl start docker

7.查看版本:

docker version

在这里插入图片描述
8.测试helloworld

docker run hello-world
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210314114347972.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0OTI2NTcx,size_16,color_FFFFFF,t_70)

9.查看一下下载的这个hello world 镜像

docker images

在这里插入图片描述
run流程图
在这里插入图片描述
底层元原理:
Docker是怎么工作的:
docker是一个Client-Server结构的系统,Docker的守护进程运行在主机上,通过Socker从客户端访问,DockerServer接受到Docker-Client的指令,就会执行这个命令。

Docker为什么biVM快
1.Docker有着比虚拟机更少的抽象层。
2.docker利用 的是宿主主机的内核,vm需要的是Guest OS

所以说,新建一个容器的时候,docker不需要像虚拟机一样重新加载一个操作系统的内核,避免引导。虚拟机时加载Guest OS,分钟级别的,而docker是利用宿主机的操作系统,省略了负载的过程

Docker的常用命令:

帮助命令:

docker version                 #docker版本信息
docker info                    #docker系统信息,包括镜像和容器数量
docker 命令 --help            #万能命令

镜像命令:
查看所有本地主机上的镜像:docker images

REPOSITORY    TAG       IMAGE ID       CREATED      SIZE
hello-world   latest    d1165f221234   8 days ago   13.3kB

**`解释:``**
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的id
CREATED 镜像的创建时间
SIZE 镜像的大小

**可选项:**
列出所有镜像:-a, —all
只显示镜像的id:-q, —quiet

**加粗样式****搜索镜像**
查找仓库源里面的镜像: docker search

**可选项:**
过滤:—filter=

```java
docker search mysql --filter=stars=3000 # 收藏数大于3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   10380     [OK]        
mariadb   MariaDB is a community-developed fork of MyS…   3848      [OK]

下载镜像

下载/拉取镜像: docker pull [OPTIONS] NAME[:TAG]

docker pull --help

Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

Options:
  -a, --all-tags                Download all tagged images in
                                the repository
      --disable-content-trust   Skip image verification
                                (default true)
      --platform string         Set platform if server is
                                multi-platform capable
  -q, --quiet                   Suppress verbose output

默认版本下载:

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
6f28985ad184: Pull complete 
e7cd18945cf6: Pull complete 
ee91068b9313: Pull complete 
b4efa1a4f93b: Pull complete 
f220edfa5893: Pull complete 
74a27d3460f8: Pull complete 
2e11e23b7542: Pull complete 
fbce32c99761: Pull complete 
08545fb3966f: Pull complete 
5b9c076841dc: Pull complete 
b7753aea2c98: Pull complete 
eb234ab12751: Pull complete 
Digest: sha256:af74f3efcbc567ed068184b5edf51392dbe8658be1b97f515ec9499f90630649
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
**指定版本下载**

```java
[root@iz2zeebo46jy1ya8zsoycwz ~]#  docker pull mysql:5.7
5.7: Pulling from library/mysql
6f28985ad184: Already exists 
e7cd18945cf6: Already exists 
ee91068b9313: Already exists 
b4efa1a4f93b: Already exists 
f220edfa5893: Already exists 
74a27d3460f8: Already exists 
2e11e23b7542: Already exists 
39ac93d44c47: Pull complete 
dfd9db50d4ea: Pull complete 
4e97f54f11a3: Pull complete 
ebfb95795c5f: Pull complete 
Digest: sha256:5f649e87093a5b6b863f5c5277b2d2aa797b04d68657494e0f28ffabfa25e781
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

在这里插入图片描述
删除镜像

通过镜像id删除
docker rmi -f 镜像id

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker rmi -f f8fcde8b9ae2
Untagged: mysql:5.7
Untagged: mysql@sha256:5f649e87093a5b6b863f5c5277b2d2aa797b04d68657494e0f28ffabfa25e781
Deleted: sha256:f8fcde8b9ae2cfdf3774f2bdf5628070e3d70b624106d55b132999e3f1685484
Deleted: sha256:3d849f301df1f08b85ac7b607dd5ebc6f6578ea35ac934b6aeaf964d3f6e014f
Deleted: sha256:69e0fe71278210fbcc60ccf53b0d86dfeefd460345fa83f675fdbce5eef37c4b
Deleted: sha256:6d2efff120dd67002624d7999876db66afeaf2aead8b7ccee4453e0d21a99628
Deleted: sha256:ad80b667eed27f25e7066ea2ebe8e4449fd997d6011f8e24dc3e5c74a7a6784e
[root@iz2zeebo46jy1ya8zsoycwz ~]# 

删除多个镜像
组合命令删除所有镜像
docker rmi -f $(docker images -aq)

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:af74f3efcbc567ed068184b5edf51392dbe8658be1b97f515ec9499f90630649
Deleted: sha256:14340cbfa9992b512feec9b7832f7e90ff867f791afa288b32d327d5ed86df15
Deleted: sha256:23d1d9828932f40c0dc6b1dcc5835d97a193d0486ff6dfb3420519cdc4ecfe24
Deleted: sha256:e0394578c23d5f9ab025e10e9e409b7109db378fb4353fb1793629cca0410b12
Deleted: sha256:88f159cadb30aacd4df26c9fb6e1fb71b3cc3f5ce05468659879216e7751bad7
Deleted: sha256:55b6e8ee7cbea49773b2a88c3941ebad16537df99b087e673ca4b0175ade1b70
Deleted: sha256:e27b1c89d3f9e194c1a3495c24a9546135ee3ab6625e94eaaedd09a41343e7d0
Deleted: sha256:c1e6768ecc0af349b2167ea29168a32da846ea4fd2ba08f37d4e45d9ee00080a
Deleted: sha256:1a0d8068bd29db71d09ff06b5356f73786f70bac70d157d2f4a1197a85aa682c
Deleted: sha256:4a52e2416c7889937a7dd82d485cc878f4d8607f20c0e77c4b0b060de457b00b
Deleted: sha256:cea5c46b3aee78a2d584f0374ab28a35995036de6b204086d34da265988e1970
Deleted: sha256:3e8ad860e72cc47bcdee6afa9c58904bbd1bc003acecaaf98393dd1c960026a6
Deleted: sha256:6f2660ea9ddbf232748e123ca4aa9f5f0ce40fef502ae2187456982b7c2efc33
Deleted: sha256:14a1ca976738392ffa2ae4e54934ba28ab9cb756e924ad9297a4795a4adbfdf6
Untagged: hello-world:latest
Untagged: hello-world@sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726
[root@iz2zeebo46jy1ya8zsoycwz ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@iz2zeebo46jy1ya8zsoycwz ~]# 

容器命令

新建容器并启动

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

新建容器并启动:
docker run 【可选参数】image

#参数说明
--name="Name"                    #容器名字
-d                                #后台运行
-it                                #使用交互方式运行,进入容器查看内容
-p                                #指定容器的端口 -p 8080:8080
    -p ip:主机端口:容器端口
    -p 主机端口:容器端口(常用)
    -p 容器端口
-P                                #随机指定端口
-e                                #配置环境遍历
-v                                #挂载卷

测试:情动并进入容器:

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker run -it centos /bin/bash
[root@4bb5aa109dc6 /]# ls
bin  etc   lib	  lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr

从容器退回主机:

[root@4bb5aa109dc6 /]# exit
exit
[root@iz2zeebo46jy1ya8zsoycwz ~]# ls
kjmblog.jar  log  nohup.out

列出所有的运行的容器
docker ps

-a #例出当前正在运行的容器,+带出历史运行过的容器
-n#显示最近创建的容器

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED         STATUS                          PORTS     NAMES
4bb5aa109dc6   centos         "/bin/bash"   3 minutes ago   Exited (0) About a minute ago             cranky_keller
9220e20ae71c   d1165f221234   "/hello"      22 hours ago    Exited (0) 22 hours ago                   intelligent_ellis

退出容器:
exit #直接容器停止并退出
Ctrl + p+q#容器不停止退出

删除容器:
docker rm 容器id
docker rm -f{docker ps -aq}

docker rm 容器id                                    #不能删除正在运行的容器
docker rm -f $(docker ps -aq)                    #删除所有容器
docker ps -a -q|xargs docker rm                    #删除所有容器

启动和停止容器的操作

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

常用的其他命令

docker run -d centos                #后台启动centos
docker ps                             #发现 centos 停止了
# docker容器使用后台运行,就必须要有一个前台进程
# 否则docker发现没有应用,就会自动停止
# nginx,容器启动后,发现自己没有提供服务,就会立刻停止

查看日志命令

docker logs -tf --tail 10 容器id
# 参数说明
-tf                                    # 显示日志
--tail number                        # 要显示日志条数

查看容器中的进程信息

docker top 容器id

查看容器的元数据

docker inspect 容器id

```java

```java
[root@iz2zeebo46jy1ya8zsoycwz ~]# docker inspect 4bb5aa109dc6
[
    {
        "Id": "4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac",
        "Created": "2021-03-15T01:16:00.528050463Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-03-15T01:16:01.047402195Z",
            "FinishedAt": "2021-03-15T01:17:52.942160987Z"
        },
        "Image": "sha256:300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55",
        "ResolvConfPath": "/var/lib/docker/containers/4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac/hostname",
        "HostsPath": "/var/lib/docker/containers/4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac/hosts",
        "LogPath": "/var/lib/docker/containers/4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac/4bb5aa109dc6c7f3acdfc3f134ef2af88625f5951d189f72a9616fe2e6c3e7ac-json.log",
        "Name": "/cranky_keller",
        "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": {

进入当前正在运行的容器

方式1

docker exec -it 容器id /bin/bash #进入容器后打开一个新的终端

方式2

docker attach 容器id #进入正在执行的,不会启动新的终端


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

docker cp 容器id:容器内文件路径 主机路径

[root@iz2zeebo46jy1ya8zsoycwz ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS         PORTS     NAMES
dc52e4f05119   centos    "/bin/bash"   3 minutes ago   Up 3 minutes             keen_pascal
[root@iz2zeebo46jy1ya8zsoycwz ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
centos       latest    300e315adb2f   3 months ago   209MB
[root@iz2zeebo46jy1ya8zsoycwz ~]# cd /home
[root@iz2zeebo46jy1ya8zsoycwz home]# touch kuangshen.java
[root@iz2zeebo46jy1ya8zsoycwz home]# ls
kuangshen.java
[root@iz2zeebo46jy1ya8zsoycwz home]# docker attch dc52e4f05119
docker: 'attch' is not a docker command.
See 'docker --help'
[root@iz2zeebo46jy1ya8zsoycwz home]# docker attach dc52e4f05119
[root@dc52e4f05119 /]# cd /home
[root@dc52e4f05119 home]# ls
[root@dc52e4f05119 home]# touch test.java
[root@dc52e4f05119 home]# exit
exit
[root@iz2zeebo46jy1ya8zsoycwz home]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@iz2zeebo46jy1ya8zsoycwz home]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                       PORTS     NAMES
dc52e4f05119   centos         "/bin/bash"   8 minutes ago    Exited (0) 19 seconds ago              keen_pascal
b827696895df   centos         "/bin/bash"   10 minutes ago   Exited (127) 9 minutes ago             gallant_poincare
4bb5aa109dc6   centos         "/bin/bash"   50 minutes ago   Exited (0) 48 minutes ago              cranky_keller
9220e20ae71c   d1165f221234   "/hello"      22 hours ago     Exited (0) 22 hours ago                intelligent_ellis
[root@iz2zeebo46jy1ya8zsoycwz home]# docker cp dc52e4f05119:/home/test.java /home
[root@iz2zeebo46jy1ya8zsoycwz home]# ls
kuangshen.java  test.java
[root@iz2zeebo46jy1ya8zsoycwz home]# 

查看docker所有容器的占cpu,内存情况

docker stats

在这里插入图片描述
在这里插入图片描述

Docker练习

安装nginx

# 搜索nginx
docker search nginx
# 下载nginx镜像
docker pull nginx
# 查看镜像
docker images
# 后台,重命名,外部端口和内部端口映射 启动
docker run -d --name nginx_1 -p 3344:80 nginx
# 测试是否成功
curl localhost:3344
# 进入nginx容器内部
docker exec -it nginx_1 /bin/bash
        # 查看nginx位置
        whereis nginx
        # 进入nginx
        cd /etc/nginx
        ls
        # 退出容器,不停止应用
        ctrl+p+q
[root@iz2zeebo46jy1ya8zsoycwz home]# docker search nginx
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                              Official build of Nginx.                        14565     [OK]       
jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   1984                 [OK]
richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   810                  [OK]
jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   162                  
linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   142                  
tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   116                  [OK]
jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        97                   [OK]
bitnami/nginx                      Bitnami nginx Docker Image                      94                   [OK]
alfg/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from sou…   89                   [OK]
jasonrivers/nginx-rtmp             Docker images to host RTMP streams using NGI…   88                   [OK]
nginxdemos/hello                   NGINX webserver that serves a simple page co…   67                   [OK]
privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   49                   [OK]
nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         49                   
nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  32                   
schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   19                   [OK]
staticfloat/nginx-certbot          Opinionated setup for automatic TLS certs lo…   19                   [OK]
nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       16                   
centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   15                   
centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   13                   
raulr/nginx-wordpress              Nginx front-end for the official wordpress:f…   13                   [OK]
flashspys/nginx-static             Super Lightweight Nginx Image                   9                    [OK]
mailu/nginx                        Mailu nginx frontend                            8                    [OK]
bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   8                    [OK]
ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          2                    [OK]
wodby/nginx                        Generic nginx                                   1                    [OK]
[root@iz2zeebo46jy1ya8zsoycwz home]# docker pull mginx
Using default tag: latest
Error response from daemon: pull access denied for mginx, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
[root@iz2zeebo46jy1ya8zsoycwz home]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
6f28985ad184: Pull complete 
29f7ebf60efd: Pull complete 
879a7c160ac6: Pull complete 
de58cd48a671: Pull complete 
be704f37b5f4: Pull complete 
158aac73782c: Pull complete 
Digest: sha256:d2925188effb4ddca9f14f162d6fba9b5fab232028aa07ae5c1dab764dca8f9f
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@iz2zeebo46jy1ya8zsoycwz home]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    6084105296a9   2 days ago     133MB
centos       latest    300e315adb2f   3 months ago   209MB
[root@iz2zeebo46jy1ya8zsoycwz home]# docker run -d --name nginx01 -p 3344:80 nginx
b4c3ef2f4d20644d09c93d5cc94ad2e34154799e0059fc2b99c0b444319e2809
[root@iz2zeebo46jy1ya8zsoycwz home]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS                  NAMES
b4c3ef2f4d20   nginx     "/docker-entrypoint.…"   10 seconds ago   Up 9 seconds   0.0.0.0:3344->80/tcp   nginx01
[root@iz2zeebo46jy1ya8zsoycwz home]# curl localhost:3344
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

```进入容器:

```java
[root@iz2zeebo46jy1ya8zsoycwz home]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                  NAMES
b4c3ef2f4d20   nginx     "/docker-entrypoint.…"   6 minutes ago   Up 6 minutes   0.0.0.0:3344->80/tcp   nginx01
[root@iz2zeebo46jy1ya8zsoycwz home]# docker exec -it nginx01 /bin/bash
root@b4c3ef2f4d20:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@b4c3ef2f4d20:/# cd /etc/nginx
root@b4c3ef2f4d20:/etc/nginx# ls
conf.d		koi-utf  mime.types  nginx.conf   uwsgi_params
fastcgi_params	koi-win  modules     scgi_params  win-utf
root@b4c3ef2f4d20:/etc/nginx# 

安装tomcat\

[root@iz2zeebo46jy1ya8zsoycwz home]# docker run -it --rm tomcat:9.0
Unable to find image 'tomcat:9.0' locally
9.0: Pulling from library/tomcat
e22122b926a1: Pull complete 
f29e09ae8373: Pull complete 
e319e3daef68: Pull complete 
e499244fe254: Pull complete 
f3c39da3e61d: Pull complete 
ff8e5bc5dc7f: Pull complete 
10a2a6a03bcc: Pull complete 
43bbfbb563b0: Pull complete 
b910288601b6: Pull complete 
6747ce19a8de: Pull complete 
Digest: sha256:cbbf9c0368fbb556967af803a9abe675336a880da41200e9ffb27854bd225c39
Status: Downloaded newer image for tomcat:9.0
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/openjdk-11
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

es+kibana

# 下载并启动
docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
# 发现服务器异常卡顿,es占用内存过高 -e 环境配置文件修改
docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTs="-Xms256m -Xmx1024m" elasticsearch:7.6.2
docker run --name kibana -e ELASTICSEARCH_URL=ip:9200 -p 5601:5601 -d kibana:7.6.2

可视化

portainer(先用着)
Docker图形化界面管理工具,提供后台面板供我们操作。

docker run -d -p 3333:9000 --restart=always --name portainer -v /var/run/docker.sock:/var/run/docker.sock  --privileged=true portainer/portainer
``

`
容器数据卷

容器的持久化和同步操作,容器间也是可以数据共享的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值