IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> docker部署及简单使用 -> 正文阅读

[系统运维]docker部署及简单使用

docker部署及简单使用

配置docker源

[root@localhost yum.repos.d]# curl -o docker-ce.repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:100  1919  100  1919    0     0  11222      0 --:--:-- --:--:-- --:--:-- 11222
[root@localhost yum.repos.d]# sed -i 's@https://download.docker.com@https://mirrors.tuna.tsinghua.edu.cn/docker-ce@g' docker-ce.repo
[root@localhost yum.repos.d]# 

安装docker

[root@localhost ~]# yum -y install docker-ce


#启动服务
[root@localhost ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
               
[root@localhost ~]# which docker
/usr/bin/docker

配置docker加速器

docker的加速有多种方式:

  • docker cn
  • 中国科技大学加速器
  • 阿里云加速器(需要通过阿里云开发者平台注册帐号,免费使用个人私有的加速器)
[root@localhost ~]# cat /etc/docker/daemon.json
{
          "registry-mirrors": ["https://k654a2v7.mirror.aliyuncs.com"]
}

重启服务


docker常用命令

docker info 查看docker加速器

[root@localhost ~]# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
  scan: Docker Scan (Docker Inc., v0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.18.0-193.el8.x86_64
 Operating System: Red Hat Enterprise Linux 8.2 (Ootpa)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.758GiB
 Name: localhost.localdomain
 ID: 3SMX:QPDX:JGEM:TUPM:CTYJ:JKWD:QVHQ:6WAS:ILE5:SCDK:4SBC:KU7V
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://k654a2v7.mirror.aliyuncs.com/
 Live Restore Enabled: false

docker version 查看docker版本信息

[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        dea9396
 Built:             Thu Nov 18 00:36:58 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:35:20 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker search 搜索Docker Hub上面的镜像

[root@localhost ~]# docker search nginx
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                             Official build of Nginx.                        15899     [OK]       
jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con…   2098                 [OK]
richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of…   819                  [OK]
jc21/nginx-proxy-manager          Docker container for managing Nginx proxy ho…   285                  
linuxserver/nginx                 An Nginx container, brought to you by LinuxS…   160                  
tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rtmp…   146                  [OK]
jlesage/nginx-proxy-manager       Docker container for Nginx Proxy Manager        144                  [OK]
alfg/nginx-rtmp                   NGINX, nginx-rtmp-module and FFmpeg from sou…   110                  [OK]
nginxdemos/hello                  NGINX webserver that serves a simple page co…   79                   [OK]
privatebin/nginx-fpm-alpine       PrivateBin running on an Nginx, php-fpm & Al…   60                   [OK]
nginx/nginx-ingress               NGINX and  NGINX Plus Ingress Controllers fo…   57                   
nginxinc/nginx-unprivileged       Unprivileged NGINX Dockerfiles                  54                   
nginxproxy/nginx-proxy            Automated Nginx reverse proxy for docker con…   28                   
staticfloat/nginx-certbot         Opinionated setup for automatic TLS certs lo…   25                   [OK]
nginx/nginx-prometheus-exporter   NGINX Prometheus Exporter for NGINX and NGIN…   22                   
schmunk42/nginx-redirect          A very simple container to redirect HTTP tra…   19                   [OK]
centos/nginx-112-centos7          Platform for running nginx 1.12 or building …   16                   
centos/nginx-18-centos7           Platform for running nginx 1.8 or building n…   13                   
flashspys/nginx-static            Super Lightweight Nginx Image                   11                   [OK]
mailu/nginx                       Mailu nginx frontend                            9                    [OK]
sophos/nginx-vts-exporter         Simple server that scrapes Nginx vts stats a…   7                    [OK]
ansibleplaybookbundle/nginx-apb   An APB to deploy NGINX                          3                    [OK]
wodby/nginx                       Generic nginx                                   1                    [OK]
arnau/nginx-gate                  Docker image with Nginx with Lua enabled on …   1                    [OK]
centos/nginx-110-centos7          Platform for running nginx 1.10 or building …   0   

docker pull 拉取镜像

[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
eff15d958d66: Pull complete 
1e5351450a59: Pull complete 
2df63e6ce2be: Pull complete 
9171c7ae368c: Pull complete 
020f975acd28: Pull complete 
266f639b35ad: Pull complete 
Digest: sha256:097c3a0913d7e3a5b01b6c685a60c03632fc7a2b50bc8e35bcaa3691d788226e
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

docker images 列出所有镜像

[root@localhost ~]# docker images 
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    ea335eea17ab   2 weeks ago   141MB

docker create 创建容器

[root@localhost ~]# docker create nginx
81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS    PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   53 seconds ago   Created             recursing_diffie


docker ps -a 列出所有已创建的容器

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS    PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   5 minutes ago   Created             recursing_diffie

docker start 启动容器

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS    PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   5 minutes ago   Created             recursing_diffie
[root@localhost ~]# docker start 81eb01f3faca
81eb01f3faca
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS          PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   7 minutes ago   Up 15 seconds   80/tcp    recursing_diffie
[root@localhost ~]# 


docker ps 列出正在运行的容器

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS          PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   7 minutes ago   Up 15 seconds   80/tcp    recursing_diffie
[root@localhost ~]# 

docker restart 重启容器

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   13 minutes ago   Up 8 seconds   80/tcp    recursing_diffie
[root@localhost ~]# docker restart 81eb01f3faca
81eb01f3faca
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS        PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   14 minutes ago   Up 1 second   80/tcp    recursing_diffie
[root@localhost ~]# docker ps

docker stop 停掉容器

[root@localhost ~]# docker stop 81eb01f3faca
81eb01f3faca
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                     PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   16 minutes ago   Exited (0) 7 seconds ago             recursing_diffie

docker kill 杀死容器进程

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   18 minutes ago   Up 6 seconds   80/tcp    recursing_diffie
[root@localhost ~]# docker kill 81eb01f3faca
81eb01f3faca
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                       PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   18 minutes ago   Exited (137) 5 seconds ago             recursing_diffie

docker run 运行

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   21 minutes ago   Up 5 seconds   80/tcp    recursing_diffie
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker run -it nginx /bin/sh
# ls
bin   dev                  docker-entrypoint.sh  home  lib64  mnt  proc  run   srv  tmp  var
boot  docker-entrypoint.d  etc                   lib   media  opt  root  sbin  sys  usr
# cd  /opt          
# ls
# pwd
/opt

docker inspect 查看容器信息

[root@localhost ~]# docker inspect 81eb01f3faca
[
    {
        "Id": "81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c",
        "Created": "2021-12-01T14:22:19.50577566Z",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 168283,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-12-01T14:43:44.647775017Z",
            "FinishedAt": "2021-12-01T14:41:09.3110278Z"
        },
        "Image": "sha256:ea335eea17ab984571cd4a3bcf90a0413773b559c75ef4cda07d0ce952b00291",
        "ResolvConfPath": "/var/lib/docker/containers/81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c/hostname",
        "HostsPath": "/var/lib/docker/containers/81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c/hosts",
        "LogPath": "/var/lib/docker/containers/81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c/81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c-json.log",
        "Name": "/recursing_diffie",
        "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/f515a4a5ff0760101b8927a198aad1f0ea4c5c10a96d0bd74432277cb79ec655-init/diff:/var/lib/docker/overlay2/acb978789132839e542bfb3110406baa27ba8650a98239b17bf7ef5c31f39034/diff:/var/lib/docker/overlay2/c019ef1aad85734b170781a7855554184609562ef9a6df03bc01cbba0fe23913/diff:/var/lib/docker/overlay2/fd092704c8512603fe54a2366e11d06cbf85997736f82bfcc5ea76f49f94064b/diff:/var/lib/docker/overlay2/fb02b62893c9535c20fec1df330540f0222cd3a4c8589d140a8afcc161bc1f98/diff:/var/lib/docker/overlay2/b9d7cc14584101f575f9bf92a3bf4ed01530195eda23d9c9bfb307327d33c657/diff:/var/lib/docker/overlay2/6ee2380a7737470340c597547f046cffb4985607a74dee64c16c835afbfb91fa/diff",
                "MergedDir": "/var/lib/docker/overlay2/f515a4a5ff0760101b8927a198aad1f0ea4c5c10a96d0bd74432277cb79ec655/merged",
                "UpperDir": "/var/lib/docker/overlay2/f515a4a5ff0760101b8927a198aad1f0ea4c5c10a96d0bd74432277cb79ec655/diff",
                "WorkDir": "/var/lib/docker/overlay2/f515a4a5ff0760101b8927a198aad1f0ea4c5c10a96d0bd74432277cb79ec655/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "81eb01f3faca",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.21.4",
                "NJS_VERSION=0.7.0",
                "PKG_RELEASE=1~bullseye"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "Image": "nginx",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "fd1fbd4f8206907dd8960c8403aa3f6ef7695e3cb1e4f452e781d497693fa085",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/fd1fbd4f8206",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "9acc7cf69247e55e0261ff475e71dc606deff3d1ee613600cc1835f85c99bdfa",
            "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": "845a0984e1009cbb47227a97b6fed582c9e1cd20b6b654c67a6bc53df27bc0e4",
                    "EndpointID": "9acc7cf69247e55e0261ff475e71dc606deff3d1ee613600cc1835f85c99bdfa",
                    "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 logs 容器日志

[root@localhost ~]# docker logs 81eb01f3faca
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:29:14 [notice] 1#1: using the "epoll" event method
2021/12/01 14:29:14 [notice] 1#1: nginx/1.21.4
2021/12/01 14:29:14 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:29:14 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:29:14 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/01 14:29:14 [notice] 1#1: start worker processes
2021/12/01 14:29:14 [notice] 1#1: start worker process 31
2021/12/01 14:29:14 [notice] 1#1: start worker process 32
2021/12/01 14:36:04 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2021/12/01 14:36:04 [notice] 31#31: gracefully shutting down
2021/12/01 14:36:04 [notice] 31#31: exiting
2021/12/01 14:36:04 [notice] 31#31: exit
2021/12/01 14:36:04 [notice] 32#32: gracefully shutting down
2021/12/01 14:36:04 [notice] 32#32: exiting
2021/12/01 14:36:04 [notice] 32#32: exit
2021/12/01 14:36:04 [notice] 1#1: signal 17 (SIGCHLD) received from 31
2021/12/01 14:36:04 [notice] 1#1: worker process 31 exited with code 0
2021/12/01 14:36:04 [notice] 1#1: signal 29 (SIGIO) received
2021/12/01 14:36:04 [notice] 1#1: signal 17 (SIGCHLD) received from 32
2021/12/01 14:36:04 [notice] 1#1: worker process 32 exited with code 0
2021/12/01 14:36:04 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:36:04 [notice] 1#1: using the "epoll" event method
2021/12/01 14:36:04 [notice] 1#1: nginx/1.21.4
2021/12/01 14:36:04 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:36:04 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:36:04 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/01 14:36:04 [notice] 1#1: start worker processes
2021/12/01 14:36:04 [notice] 1#1: start worker process 24
2021/12/01 14:36:04 [notice] 1#1: start worker process 25
2021/12/01 14:36:33 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2021/12/01 14:36:33 [notice] 25#25: gracefully shutting down
2021/12/01 14:36:33 [notice] 24#24: gracefully shutting down
2021/12/01 14:36:33 [notice] 25#25: exiting
2021/12/01 14:36:33 [notice] 24#24: exiting
2021/12/01 14:36:33 [notice] 25#25: exit
2021/12/01 14:36:33 [notice] 24#24: exit
2021/12/01 14:36:33 [notice] 1#1: signal 17 (SIGCHLD) received from 25
2021/12/01 14:36:33 [notice] 1#1: worker process 25 exited with code 0
2021/12/01 14:36:33 [notice] 1#1: signal 29 (SIGIO) received
2021/12/01 14:36:33 [notice] 1#1: signal 17 (SIGCHLD) received from 24
2021/12/01 14:36:33 [notice] 1#1: worker process 24 exited with code 0
2021/12/01 14:36:33 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:36:34 [notice] 1#1: using the "epoll" event method
2021/12/01 14:36:34 [notice] 1#1: nginx/1.21.4
2021/12/01 14:36:34 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:36:34 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:36:34 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/01 14:36:34 [notice] 1#1: start worker processes
2021/12/01 14:36:34 [notice] 1#1: start worker process 25
2021/12/01 14:36:34 [notice] 1#1: start worker process 26
2021/12/01 14:36:59 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2021/12/01 14:36:59 [notice] 25#25: gracefully shutting down
2021/12/01 14:36:59 [notice] 26#26: gracefully shutting down
2021/12/01 14:36:59 [notice] 25#25: exiting
2021/12/01 14:36:59 [notice] 26#26: exiting
2021/12/01 14:36:59 [notice] 25#25: exit
2021/12/01 14:36:59 [notice] 26#26: exit
2021/12/01 14:36:59 [notice] 1#1: signal 17 (SIGCHLD) received from 25
2021/12/01 14:36:59 [notice] 1#1: worker process 25 exited with code 0
2021/12/01 14:36:59 [notice] 1#1: signal 29 (SIGIO) received
2021/12/01 14:36:59 [notice] 1#1: signal 17 (SIGCHLD) received from 26
2021/12/01 14:36:59 [notice] 1#1: worker process 26 exited with code 0
2021/12/01 14:36:59 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
2021/12/01 14:36:59 [notice] 1#1: using the "epoll" event method
2021/12/01 14:36:59 [notice] 1#1: nginx/1.21.4
2021/12/01 14:36:59 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:36:59 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:36:59 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/01 14:36:59 [notice] 1#1: start worker processes
2021/12/01 14:36:59 [notice] 1#1: start worker process 25
2021/12/01 14:36:59 [notice] 1#1: start worker process 26
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:38:39 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2021/12/01 14:38:39 [notice] 26#26: gracefully shutting down
2021/12/01 14:38:39 [notice] 26#26: exiting
2021/12/01 14:38:39 [notice] 26#26: exit
2021/12/01 14:38:39 [notice] 25#25: gracefully shutting down
2021/12/01 14:38:39 [notice] 25#25: exiting
2021/12/01 14:38:39 [notice] 25#25: exit
2021/12/01 14:38:39 [notice] 1#1: signal 17 (SIGCHLD) received from 26
2021/12/01 14:38:39 [notice] 1#1: worker process 26 exited with code 0
2021/12/01 14:38:39 [notice] 1#1: signal 29 (SIGIO) received
2021/12/01 14:38:39 [notice] 1#1: signal 17 (SIGCHLD) received from 25
2021/12/01 14:38:39 [notice] 1#1: worker process 25 exited with code 0
2021/12/01 14:38:39 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:40:49 [notice] 1#1: using the "epoll" event method
2021/12/01 14:40:49 [notice] 1#1: nginx/1.21.4
2021/12/01 14:40:49 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:40:49 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:40:49 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/01 14:40:49 [notice] 1#1: start worker processes
2021/12/01 14:40:49 [notice] 1#1: start worker process 24
2021/12/01 14:40:49 [notice] 1#1: start worker process 25
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
2021/12/01 14:43:44 [notice] 1#1: using the "epoll" event method
2021/12/01 14:43:44 [notice] 1#1: nginx/1.21.4
2021/12/01 14:43:44 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/01 14:43:44 [notice] 1#1: OS: Linux 4.18.0-193.el8.x86_64
2021/12/01 14:43:44 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/01 14:43:44 [notice] 1#1: start worker processes
2021/12/01 14:43:44 [notice] 1#1: start worker process 25
2021/12/01 14:43:44 [notice] 1#1: start worker process 26
172.17.0.1 - - [01/Dec/2021:15:05:41 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/7.61.1" "-"

docker rm 删除容器

[root@localhost ~]# docker ps -aq  # 列出所有容器id
a66bd85035d7
ba03d62c1a1b
ba153f0663c3
7d79957b18f6
81eb01f3faca
[root@localhost ~]# docker rm $(docker ps -aq)      #删除所有容器,正在运行的容器无法删除
a66bd85035d7
ba03d62c1a1b
ba153f0663c3
7d79957b18f6
Error response from daemon: You cannot remove a running container 81eb01f3facab5c6c7b31a6b993ccb170a46acda577925073f8c0c53f564a01c. Stop the container before attempting removal or force remove
[root@localhost ~]# docker rm  a66bd85035d7  #删除单个容器

docker attach 进入容器,一次性,推出后容器停止

[root@localhost ~]# docker attach 81eb01f3faca
2021/12/01 15:24:12 [notice] 1#1: signal 28 (SIGWINCH) received

ls
^C2021/12/01 15:24:17 [notice] 1#1: signal 2 (SIGINT) received, exiting
2021/12/01 15:24:17 [notice] 25#25: exiting
2021/12/01 15:24:17 [notice] 26#26: exiting
2021/12/01 15:24:17 [notice] 26#26: exit
2021/12/01 15:24:17 [notice] 25#25: exit
2021/12/01 15:24:17 [notice] 1#1: signal 17 (SIGCHLD) received from 25
2021/12/01 15:24:17 [notice] 1#1: worker process 25 exited with code 0
2021/12/01 15:24:17 [notice] 1#1: signal 29 (SIGIO) received
2021/12/01 15:24:17 [notice] 1#1: signal 17 (SIGCHLD) received from 26
2021/12/01 15:24:17 [notice] 1#1: worker process 26 exited with code 0
2021/12/01 15:24:17 [notice] 1#1: exit
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# 

docker exec 进入容器

[root@localhost ~]# docker exec -it  81eb01f3faca /bin/bash
root@81eb01f3faca:/# ls
bin                   etc    mnt   sbin  var
boot                  home   opt   srv
dev                   lib    proc  sys
docker-entrypoint.d   lib64  root  tmp
docker-entrypoint.sh  media  run   usr
root@81eb01f3faca:/# ip a
bash: ip: command not found
root@81eb01f3faca:/# exit
exit
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED             STATUS              PORTS     NAMES
81eb01f3faca   nginx     "/docker-entrypoint.…"   About an hour ago   Up About a minute   80/tcp    recursing_diffie

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2021-12-02 17:10:50  更:2021-12-02 17:12:13 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/16 2:48:03-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码