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  CurrentDload  Upload   Total   Spent    Left  Speed0     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:    defaultDebug Mode: falsePlugins: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: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 20.10.11Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueNative 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 io.containerd.runtime.v1.linux runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5drunc version: v1.0.2-0-g52b36a2init version: de40ad0Security Options:seccompProfile: defaultKernel Version: 4.18.0-193.el8.x86_64Operating System: Red Hat Enterprise Linux 8.2 (Ootpa)OSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 1.758GiBName: localhost.localdomainID: 3SMX:QPDX:JGEM:TUPM:CTYJ:JKWD:QVHQ:6WAS:ILE5:SCDK:4SBC:KU7VDocker Root Dir: /var/lib/dockerDebug Mode: falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://k654a2v7.mirror.aliyuncs.com/Live Restore Enabled: false

docker version 查看docker版本信息

[root@localhost ~]# docker version
Client: Docker Engine - CommunityVersion:           20.10.11API version:       1.41Go version:        go1.16.9Git commit:        dea9396Built:             Thu Nov 18 00:36:58 2021OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer: Docker Engine - CommunityEngine:Version:          20.10.11API version:      1.41 (minimum version 1.12)Go version:       go1.16.9Git commit:       847da18Built:            Thu Nov 18 00:35:20 2021OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          1.4.12GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5drunc:Version:          1.0.2GitCommit:        v1.0.2-0-g52b36a2docker-init:Version:          0.19.0GitCommit:        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) receivedls
^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

docker部署及简单使用相关推荐

  1. 通过docker部署一个简单的web服务

    前面把redis.oracle都部署好了,还有最后两步: 1)docker镜像制作和启动 2)redis和oracle都在vitualbox中,防火墙问题等等 docker 镜像及制作 首先安装好do ...

  2. 用docker部署go简单应用

    1.首先使用go语言实现基本http服务 使用echo标准库实现8080端口输出helloworld的服务. 安装echo mygohttp.go: import ("github.com/ ...

  3. 使用docker部署nginx搭建简单的idea-2019 jrebel插件激活服务器

    使用docker部署nginx搭建简单的idea-2019 jrebel插件激活服务器 前言 之前用的jrebel激活方式一直都是用的 *lanyus* 大神的 [jrebel激活](http://i ...

  4. 学习Docker之Docker初体验 简单用例---SpringBoot集成Docker的部署、发布与应用

    简单用例 简单的创建一个工程,实现一个接口即可,然后在pom中添加docker插件,相关代码如下 @SpringBootApplication @RestController public class ...

  5. 手牵手教Docker部署Springboot+vue ,全过程十分详细,轻松完成项目部署(简单,高效,通用)

    手把手教Docker部署Springboot+vue ,详细全过程,轻松完成项目部署(简单,高效) 上线前准备 腾讯云的服务器,服务器安装好docker 和docker-compose 最好事先了解技 ...

  6. 史上最简单的docker入门到放弃——(利用docker部署web应用)

    目录 @[TOC](目录) 第一章 什么是docker 1.1 docker的发展史 1.2 docker国内应用史 1.3 什么是Docker 第二章 了解docker 2.1 docker思想 2 ...

  7. Docker 部署SpringBoot项目不香吗?

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 作者:流星007 链接:toutiao.com/i68433912 ...

  8. docker部署springboot_Docker+SpringBoot快速构建和部署应用

    前言 Docker技术发展为当前流行的微服务提供了更加便利的环境,使用SpringBoot+Docker部署和发布应用,其实也是一件比较简单的事情.当前,前提是得有Docker的基础. 构建一个Spr ...

  9. Docker系列 四.Docker部署SpringBoot

    四.Docker部署SpringBoot 环境&工具: 阿里云轻量级服务器.CentOS 7系统.FinalShell(其他连接客户端也可以).IDEA 1. 创建springboot项目 这 ...

最新文章

  1. HDU1599(最小环)
  2. 一线技术管理者究竟在管什么事?
  3. 碎片化学习的三大障碍及破解之道
  4. [密码学基础][每个信息安全博士生应该知道的52件事][Bristol Cryptography][第22篇]如何用蒙哥马利算法表示一个数字和多个相乘的数字
  5. IDC:2016年第四季度全球企业存储市场出现下滑
  6. openresty lua集成kafka
  7. 黑龙江工程学院锐捷校园网连接路由器免认证
  8. php大马2022亲测可用,绕过waf无加密版本
  9. DEM、DSM 和 DTM 的区别——GIS 中的高程模型
  10. 推荐一款开源的电子书格式转换工具
  11. 有道云生成html,从有道云笔记迁移到为知笔记
  12. 2022年4月份京东有什么活动?
  13. win10无限蓝屏_Win10升级系统后蓝屏或无限重启的解决方法
  14. Zigbee通讯之开发篇(基于TI 的Z-Stack)
  15. beeline执行sql语句_beeline执行sql脚本我世界开挂
  16. 淘宝客如何通过小红书引流?如何找出你的目标人群有哪些?
  17. Java小白自学8:循环结构练习题(一)
  18. WebRTC ADM 源码流程分析
  19. 数独生成算法的简单实现
  20. 一加手机6t鸿蒙rom,一加6T官方原厂固件rom系统全量刷机包下载_OnePlus 6T升级包

热门文章

  1. GEE水体提取之NDWI(矢量裁剪、统计面积、数据导出)
  2. android机顶盒简单案例
  3. 纺织服装出口大国PK
  4. Win8 建行网银解决方案
  5. 这款IDEA插件刷爆了朋友圈,网友:一定是女朋友送的~
  6. 操作系统是管理计算机系统资源,操作系统是计算机资源的管理者
  7. 如何在小程序内使用流式布局实现动态相册效果?
  8. 苹果cmsv8手机免费黑色影视模板源码
  9. C++ Primer 第四章
  10. mysql查询之,本日,本年,本周,本月查询,按小时,日期,月份..进行统计