初次学习Docker没什么经验记录下的笔记

1.卸载旧的版本
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine

linux命令
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
这是卸载完成之后出来的

2.需要的安装包
yum install -y yum-utils

Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
安装之后出现的,nothing to do代表我之前有
3.设置镜像的仓库
yum-config-manager
–add-repo
https://download.docker.com/linux/centos/docker-ce.repo
默认路径是国外的速度很慢
yum-config-manager
–add-repo
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
这是国内阿里云的路径 速度会很快

Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

这是安装之后出现的

yum更新 更新缓存
yum makecache fast

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 62 kB 00:00:00
Metadata Cache Created
这是运行过后的

4.安装docker相关的内容 docker-ce 社区版 docker-ee企业版
yum install docker-ce docker-ce-cli containerd.io

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package containerd.io.x86_64 0:1.4.6-3.1.el7 will be installed
–> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.6-3.1.el7.x86_64
—> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed
–> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.7-3.el7.x86_64
–> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.7-3.el7.x86_64
—> Package docker-ce-cli.x86_64 1:20.10.7-3.el7 will be installed
–> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.7-3.el7.x86_64
–> Running transaction check
—> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
–> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
—> Package docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 will be installed
–> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
–> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
—> Package docker-scan-plugin.x86_64 0:0.8.0-3.el7 will be installed
—> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
–> Running transaction check
—> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
–> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
–> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
–> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
—> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
–> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
–> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
—> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
–> Running transaction check
—> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
—> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
—> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
—> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
—> Package python-IPy.noarch 0:0.75-6.el7 will be installed
—> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
Package Arch Version Repository Size

Installing:
containerd.io x86_64 1.4.6-3.1.el7 docker-ce-stable 34 M
docker-ce x86_64 3:20.10.7-3.el7 docker-ce-stable 27 M
docker-ce-cli x86_64 1:20.10.7-3.el7 docker-ce-stable 33 M
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 os 76 k
checkpolicy x86_64 2.5-8.el7 os 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras x86_64 20.10.7-3.el7 docker-ce-stable 9.2 M
docker-scan-plugin x86_64 0.8.0-3.el7 docker-ce-stable 4.2 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
libcgroup x86_64 0.41-21.el7 os 66 k
libsemanage-python x86_64 2.5-14.el7 os 113 k
policycoreutils-python x86_64 2.5-34.el7 os 457 k
python-IPy noarch 0.75-6.el7 os 32 k
setools-libs x86_64 3.3.8-4.el7 os 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k

Transaction Summary

Install 3 Packages (+13 Dependent packages)

Total download size: 108 M
Installed size: 444 M
Is this ok [y/d/N]: y
Downloading packages:
(1/16): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(2/16): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(3/16): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.7-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.7-3.el7.x86_64.rpm is not installed
(4/16): docker-ce-20.10.7-3.el7.x86_64.rpm | 27 MB 00:00:50
(5/16): containerd.io-1.4.6-3.1.el7.x86_64.rpm | 34 MB 00:00:52
(6/16): docker-ce-rootless-extras-20.10.7-3.el7.x86_64.rpm | 9.2 MB 00:00:15
(7/16): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(8/16): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(9/16): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(10/16): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(11/16): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(12/16): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(13/16): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(14/16): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(15/16): docker-scan-plugin-0.8.0-3.el7.x86_64.rpm | 4.2 MB 00:00:06
(16/16): docker-ce-cli-20.10.7-3.el7.x86_64.rpm | 33 MB 00:01:05

Total 958 kB/s | 108 MB 00:01:55
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : “Docker Release (CE rpm) docker@docker.com
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-21.el7.x86_64 1/16
Installing : 1:docker-ce-cli-20.10.7-3.el7.x86_64 2/16
Installing : docker-scan-plugin-0.8.0-3.el7.x86_64 3/16
Installing : setools-libs-3.3.8-4.el7.x86_64 4/16
Installing : python-IPy-0.75-6.el7.noarch 5/16
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 6/16
Installing : libsemanage-python-2.5-14.el7.x86_64 7/16
Installing : audit-libs-python-2.8.5-4.el7.x86_64 8/16
Installing : fuse3-libs-3.6.1-4.el7.x86_64 9/16
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 10/16
Installing : checkpolicy-2.5-8.el7.x86_64 11/16
Installing : policycoreutils-python-2.5-34.el7.x86_64 12/16
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 13/16
setsebool: SELinux is disabled.
Installing : containerd.io-1.4.6-3.1.el7.x86_64 14/16
Installing : docker-ce-rootless-extras-20.10.7-3.el7.x86_64 15/16
Installing : 3:docker-ce-20.10.7-3.el7.x86_64 16/16
Verifying : containerd.io-1.4.6-3.1.el7.x86_64 1/16
Verifying : checkpolicy-2.5-8.el7.x86_64 2/16
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 3/16
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 4/16
Verifying : docker-scan-plugin-0.8.0-3.el7.x86_64 5/16
Verifying : libsemanage-python-2.5-14.el7.x86_64 6/16
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 7/16
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 8/16
Verifying : python-IPy-0.75-6.el7.noarch 9/16
Verifying : policycoreutils-python-2.5-34.el7.x86_64 10/16
Verifying : 3:docker-ce-20.10.7-3.el7.x86_64 11/16
Verifying : 1:docker-ce-cli-20.10.7-3.el7.x86_64 12/16
Verifying : setools-libs-3.3.8-4.el7.x86_64 13/16
Verifying : docker-ce-rootless-extras-20.10.7-3.el7.x86_64 14/16
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 15/16
Verifying : libcgroup-0.41-21.el7.x86_64 16/16

Installed:
containerd.io.x86_64 0:1.4.6-3.1.el7 docker-ce.x86_64 3:20.10.7-3.el7
docker-ce-cli.x86_64 1:20.10.7-3.el7

Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7
docker-scan-plugin.x86_64 0:0.8.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7
libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8

Complete!
这是安装之后出现的东西,中间需要输入两次Y 同意什么什么。。。。。。没翻译

5.启动docker
systemctl start docker
不出现任何东西
6.可以用这个命令来查看启动情况 查看是否安装成功
docker version
Client: Docker Engine - Community
Version: 20.10.7
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:58:10 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:56:35 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.6
GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit: de40ad0

这是执行完docker version之后出现的东西

7.启动命令

Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:9f6ad537c5132bcce57f7a0a20e317228d382c3cd61edae14650eec68b2b345c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
    (amd64)
  3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

没找到图片然后去下载图片去了,这是命令过后出现的东西

8.查看一下下载下来的hall word
docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 4 months ago 13.3kB

9.卸载docker
如果不用docker 的话就两步,卸载docker 依赖然后删除资源
yum remove docker-ce docker-ce-cli containerd.io
第一步

rm -rf /var/lib/docker docker的默认工作路径
rm -rf /var/lib/containerd
第二步

登录阿里云,找到镜像加速地址和位置
然后配置镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://bhpsej3d.mirror.aliyuncs.com”]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
这是四个命令 sudo为开头
第一个命令是创建文件夹
第二个命令是配置自己的镜像加速器地址
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://bhpsej3d.mirror.aliyuncs.com”]
}
EOF
第三个是重新载入配置文件
第四个是重启docker

docker 的run 运行流程 运行分析
第一步是docker现在本机寻找镜像
第二步如果本机有这个镜像的话就会运行,如果没有的话就去hub上下载 如果hub上有的话就下载然后使用,如果没有的话就返回错误,找不到镜像

docker是怎么工作的呢?
docker是一个client-server结构的系统,docker的守护进程运行在主机上,通过socket从客户端访问
dockerserver接收到docker-client的指令,就会执行这个命令

docker为什么比VM块
因为docker有着比虚拟机更少的抽象层
docker利用的是宿主机的内核,而VM是需要guest os
所以说新建一个容器的时候docker不需要向虚拟机一样诚信加载一个操作系统内核避免引导,虚拟机是加载guest os 分钟级别的,二docker是利用宿主机的操作系统,级别是秒级的。

docker命令的文档
https://docs.docker.com/engine/reference/run/
docker的常用命令

docker version 查看版本信息
docker info 可以看docker 更加详细的信息,相比于version来说,显示系统信息,包括镜像和容器的数量
docker 命令 --help 这是一个万能命令

镜像命令

docker images 查看所有本机的镜像包括仓库
REPOSITORY TAG IMAGE ID CREATED SIZE
repository 镜像的仓库源,名字
tag 镜像的标签
image id 镜像的ID
created 镜像的创建时间
size 镜像的大小
-a, --all Show all images (default hides intermediate images) 列出所有的镜像
–digests Show digests
-f, --filter filter Filter output based on conditions provided
–format string Pretty-print images using a Go template
–no-trunc Don’t truncate output
-q, --quiet Only show image IDs 只显示镜像的ID
-aq 显示所有镜像的id
可选项
docker search 搜索镜像 后面加你想搜的东西 mysql 或tomcat 等
-f, --filter filter Filter output based on conditions provided 你可以过滤一些通过,相当于模糊查询了
–format string Pretty-print search using a Go template
–limit int Max number of search results (default 25)
–no-trunc Don’t truncate output
可选项
–filter=stars=3000 搜索出来的镜像就是收藏大于三千的要不然出现的东西太多

docker pull 下载命令
-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
可选项
docker pull mysql
docker pull docker.io/library/mysql:latest
这两个命令相同,一个是指定路径一个是不指定路径但是有默认路径
docker pull mysql:tag tag 为版本,如果不写版本的话默认就是最后一个
docker pull mysql:5.7
这是往docker里面下载mysql
5.7: Pulling from library/mysql
b4d181a07f80: Pull complete
a462b60610f5: Pull complete
578fafb77ab8: Pull complete
524046006037: Pull complete
d0cbe54c8855: Pull complete
aa18e05cc46d: Pull complete
32ca814c833f: Pull complete
52645b4af634: Pull complete
bca6a5b14385: Pull complete
309f36297c75: Pull complete
7d75cacde0f8: Pull complete
Digest: sha256:1a2f9cd257e75cc80e9118b303d1648366bc2049101449bf2c8d82b022ea86b7
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
这是下载回执,指定了版本未指定路径,但是又默认路径

docker rmi
docker rmi -f 是全部删掉 后面可以加ID然后单独删除 通过空格来增加ID 可以达到批量删除的结果
docker rmi -f $(docker images -aq) 这个是递归删除 删docker镜像库跑路用的一般用不上哈,自己的可以尝试,公司的千万不要尝试

以上四个镜像命令,总结起来就是增删查,曾加 pull 删除 rmi 查询 images

容器命令
新建容器并启动
docker pull centos
等于说再docker里面下载一个centos容器
7a0437f04f83: Pull complete
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
此为回执
docker run [可选参数] image
–add-host list Add a custom host-to-IP mapping (host:ip)
-a, --attach list Attach to STDIN, STDOUT or STDERR
–blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to
disable (default 0)
–blkio-weight-device list Block IO weight (relative device weight) (default [])
–cap-add list Add Linux capabilities
–cap-drop list Drop Linux capabilities
–cgroup-parent string Optional parent cgroup for the container
–cgroupns string Cgroup namespace to use (host|private)
‘host’: Run the container in the Docker host’s cgroup
namespace
‘private’: Run the container in its own private cgroup
namespace
‘’: Use the cgroup namespace as configured by the
default-cgroupns-mode option on the daemon (default)
–cidfile string Write the container ID to the file
–cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
–cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
–cpu-rt-period int Limit CPU real-time period in microseconds
–cpu-rt-runtime int Limit CPU real-time runtime in microseconds
-c, --cpu-shares int CPU shares (relative weight)
–cpus decimal Number of CPUs
–cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
–cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
-d, --detach Run container in background and print container ID
–detach-keys string Override the key sequence for detaching a container
–device list Add a host device to the container
–device-cgroup-rule list Add a rule to the cgroup allowed devices list
–device-read-bps list Limit read rate (bytes per second) from a device (default [])
–device-read-iops list Limit read rate (IO per second) from a device (default [])
–device-write-bps list Limit write rate (bytes per second) to a device (default [])
–device-write-iops list Limit write rate (IO per second) to a device (default [])
–disable-content-trust Skip image verification (default true)
–dns list Set custom DNS servers
–dns-option list Set DNS options
–dns-search list Set custom DNS search domains
–domainname string Container NIS domain name
–entrypoint string Overwrite the default ENTRYPOINT of the image
-e, --env list Set environment variables
–env-file list Read in a file of environment variables
–expose list Expose a port or a range of ports
–gpus gpu-request GPU devices to add to the container (‘all’ to pass all GPUs)
–group-add list Add additional groups to join
–health-cmd string Command to run to check health
–health-interval duration Time between running the check (ms|s|m|h) (default 0s)
–health-retries int Consecutive failures needed to report unhealthy
–health-start-period duration Start period for the container to initialize before starting
health-retries countdown (ms|s|m|h) (default 0s)
–health-timeout duration Maximum time to allow one check to run (ms|s|m|h) (default 0s)
–help Print usage
-h, --hostname string Container host name
–init Run an init inside the container that forwards signals and
reaps processes
-i, --interactive Keep STDIN open even if not attached
–ip string IPv4 address (e.g., 172.30.100.104)
–ip6 string IPv6 address (e.g., 2001:db8::33)
–ipc string IPC mode to use
–isolation string Container isolation technology
–kernel-memory bytes Kernel memory limit
-l, --label list Set meta data on a container
–label-file list Read in a line delimited file of labels
–link list Add link to another container
–link-local-ip list Container IPv4/IPv6 link-local addresses
–log-driver string Logging driver for the container
–log-opt list Log driver options
–mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33)
-m, --memory bytes Memory limit
–memory-reservation bytes Memory soft limit
–memory-swap bytes Swap limit equal to memory plus swap: ‘-1’ to enable
unlimited swap
–memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
–mount mount Attach a filesystem mount to the container
–name string Assign a name to the container
–network network Connect a container to a network
–network-alias list Add network-scoped alias for the container
–no-healthcheck Disable any container-specified HEALTHCHECK
–oom-kill-disable Disable OOM Killer
–oom-score-adj int Tune host’s OOM preferences (-1000 to 1000)
–pid string PID namespace to use
–pids-limit int Tune container pids limit (set -1 for unlimited)
–platform string Set platform if server is multi-platform capable
–privileged Give extended privileges to this container
-p, --publish list Publish a container’s port(s) to the host
-P, --publish-all Publish all exposed ports to random ports
–pull string Pull image before running (“always”|“missing”|“never”)
(default “missing”)
–read-only Mount the container’s root filesystem as read only
–restart string Restart policy to apply when a container exits (default “no”)
–rm Automatically remove the container when it exits
–runtime string Runtime to use for this container
–security-opt list Security Options
–shm-size bytes Size of /dev/shm
–sig-proxy Proxy received signals to the process (default true)
–stop-signal string Signal to stop a container (default “SIGTERM”)
–stop-timeout int Timeout (in seconds) to stop a container
–storage-opt list Storage driver options for the container
–sysctl map Sysctl options (default map[])
–tmpfs list Mount a tmpfs directory
-t, --tty Allocate a pseudo-TTY
–ulimit ulimit Ulimit options (default [])
-u, --user string Username or UID (format: <name|uid>[:<group|gid>])
–userns string User namespace to use
–uts string UTS namespace to use
-v, --volume list Bind mount a volume
–volume-driver string Optional volume driver for the container
–volumes-from list Mount volumes from the specified container(s)
-w, --workdir string Working directory inside the container
可选项

参数名字 --name=“name” 容器名字 用来区分名字
-d 后台方式运行
-it 使用交互方式运行,进入容器查看内容
-p 指定容器的端口 -p 主机端口:容器端口 -p ip:主机端口:容器端口
-P 随机指定端口

docker run -it centos /bin/bash 启动并进入容器
进去之后是镜像ID
ls 查看容器内的centos 基础版本 很多命令不完善

exit 从容器中退出到主机并停止容器
ctrl + p + q 跳回主机不停止容器

docker ps 查看正在运行的容器
docker ps -a 查看正在运行的容器也查看曾经运行过的
docker ps -n 显示最近创建的容器
docker ps -q 只显示容器的编号 -aq显示所有的容器编号也就是ID

docker rm +容器ID 删除容器 不能删除正在运行中的容器
docker rm -f $(docker ps -aq) 递归删除所有容器
docker ps -a -q|xargs docker rm 删除所有容器

启动和通知容器的操作
docker start +容器ID 来运行容器
docker restart + 容器id 重启容器
docker stop +容器id 停止正在运行的容器
docker kill +容器id 强制停止当前容器

以上镜像命令和容器命令是基础命令
docker run -d +容器的名字
容器启动后,如果自己发现没有提供任何服务就会立即自杀,停止服务

docker logs 查看日志
–details Show extra details provided to logs
-f, --follow Follow log output
–since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m
for 42 minutes)
-n, --tail string Number of lines to show from the end of the logs (default “all”)
-t, --timestamps Show timestamps
–until string Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g.
42m for 42 minutes)
可选项

docker logs -f -t --tail +镜像id
docker logs -t -f --tail 10 镜像id 查看指定行数的日志
docker logs -t -f --tail 10 镜像id 查看所有日志

docker top + 镜像ID 查看 容器中的进程信息

查看镜像的源数据
docker inspect + 镜像id 查看镜像的源数据,详细信息,超级详细
-f, --format string Format the output using the given Go template
-s, --size Display total file sizes if the type is container
–type string Return JSON for specified type
可选项

进入当前正在运行的容器 进入容器修改一些配置
docker exec -it +容器ID /bin/bash
docker attach +容器id
两个都可以进入容器哦 区别是第二个是正在执行,可以进去查看日志哦,第一个是打开一个新的终端,可以在里面操作

docker cp + 容器id:容器内路径 目的地的路径
docker cp 容器id:容器内路径 拷贝地址的路径

docker 命令非常多 加油奥里给

安装nginx
docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Already exists
66b1c490df3f: Pull complete
d0f91ae9b44c: Pull complete
baf987068537: Pull complete
6bbc76cbebeb: Pull complete
32b766478bc2: Pull complete
Digest: sha256:3ca76089b14cf7db77cc5d4f3e9c9eb73768b9c85a0eabde1046435a6aa41c06
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
下载回执

linux 开启某个端口号命令
linux开放端口命令

1、开启防火墙
systemctl start firewalld

2、开放指定端口
firewall-cmd --zone=public --add-port=3355/tcp --permanent
命令含义:
–zone #作用域
–add-port=1935/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

3、重启防火墙
firewall-cmd --reload

4、查看端口号
netstat -ntlp //查看当前所有tcp端口·

netstat -ntulp |grep 3355//查看所有1935端口使用情况·

docker nginx 的玩法 包括命令以及回执 和开端口等等

[root@VM-0-10-centos ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Already exists
66b1c490df3f: Pull complete
d0f91ae9b44c: Pull complete
baf987068537: Pull complete
6bbc76cbebeb: Pull complete
32b766478bc2: Pull complete
Digest: sha256:3ca76089b14cf7db77cc5d4f3e9c9eb73768b9c85a0eabde1046435a6aa41c06
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@VM-0-10-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos ~]# docker run -d --name nginx01 -p 3344:80 nginx
d22002127f9147c8d2718b9c9cdadfa8db5e8c31eb5104742ab4eda48bc37f80
[root@VM-0-10-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d22002127f91 nginx “/docker-entrypoint.…” 2 seconds ago Up 2 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
[root@VM-0-10-centos ~]# cd home
-bash: cd: home: No such file or directory
[root@VM-0-10-centos ~]# cd /home
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d22002127f91 nginx “/docker-entrypoint.…” 27 seconds ago Up 27 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
[root@VM-0-10-centos home]# firewall-cmd --query-port=3344/tcp
FirewallD is not running
[root@VM-0-10-centos home]# firewall-cmd --add-port=3344/tcp --permanent
FirewallD is not running
[root@VM-0-10-centos home]# firewall-cmd --query-port=3344/tcp
FirewallD is not running
[root@VM-0-10-centos home]# firewall-cmd --query-port=3344/tcp
FirewallD is not running
[root@VM-0-10-centos home]# iptables -L -v
Chain INPUT (policy ACCEPT 1326 packets, 95556 bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DOCKER-USER all – any any anywhere anywhere
0 0 DOCKER-ISOLATION-STAGE-1 all – any any anywhere anywhere
0 0 ACCEPT all – any docker0 anywhere anywhere ctstate RELATED,ESTABLISHED
0 0 DOCKER all – any docker0 anywhere anywhere
0 0 ACCEPT all – docker0 !docker0 anywhere anywhere
0 0 ACCEPT all – docker0 docker0 anywhere anywhere

Chain OUTPUT (policy ACCEPT 1232 packets, 193K bytes)
pkts bytes target prot opt in out source destination

Chain DOCKER (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp – !docker0 docker0 anywhere 172.17.0.2 tcp dpt:http

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
pkts bytes target prot opt in out source destination
0 0 DOCKER-ISOLATION-STAGE-2 all – docker0 !docker0 anywhere anywhere
0 0 RETURN all – any any anywhere anywhere

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
pkts bytes target prot opt in out source destination
0 0 DROP all – any docker0 anywhere anywhere
0 0 RETURN all – any any anywhere anywhere

Chain DOCKER-USER (1 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all – any any anywhere anywhere
[root@VM-0-10-centos home]# systemctl start firewalld
[root@VM-0-10-centos home]# firewall-cmd --zone=public --add-port=3344/tcp --permanent
success
[root@VM-0-10-centos home]# firewall-cmd --reload
success
[root@VM-0-10-centos home]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3344 0.0.0.0:* LISTEN 26863/docker-proxy
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1343/sshd
tcp6 0 0 :::3344 ::😗 LISTEN 26867/docker-proxy
[root@VM-0-10-centos home]# curl localhost:3344

Welcome to nginx!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

docker exec -it nginx01 /bin/bash
whereis nginx
cd /tec/nginx
ls
这是进入正在运行的容器,然后进入nginx 的目录,可以在里面修改配置信息,然后重启nginx 等操作

docker run -it --rm tomcat:9.0 这主要是用来测试的,用完就删除的道理

docker pull tomcat:9.0
运行tomcat
docker run -d -p 3355:8080 --name tomcat01 tomcat
docker exec -it tomcat01 /bin/bash

从tomcat 的代码记录记录

[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker run -it --rm tomcat:9.0
Unable to find image ‘tomcat:9.0’ locally
9.0: Pulling from library/tomcat
0bc3020d05f1: Pull complete
a110e5871660: Pull complete
83d3c0fa203a: Pull complete
a8fd09c11b02: Pull complete
96ebf1506065: Pull complete
b8bf70f9cc4d: Pull complete
3f6da67b9e68: Pull complete
257407776119: Pull complete
7bd0a187fb92: Pull complete
307fc4df04c9: Pull complete
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
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
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
07-Jul-2021 07:45:25.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.50
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 28 2021 08:46:44 UTC
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.50.0
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-1160.11.1.el7.x86_64
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-11
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.11+9
07-Jul-2021 07:45:25.630 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
07-Jul-2021 07:45:25.631 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
07-Jul-2021 07:45:25.631 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
07-Jul-2021 07:45:25.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
07-Jul-2021 07:45:25.652 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
07-Jul-2021 07:45:25.702 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.30] using APR version [1.6.5].
07-Jul-2021 07:45:25.703 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
07-Jul-2021 07:45:25.703 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
07-Jul-2021 07:45:25.717 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1d 10 Sep 2019]
07-Jul-2021 07:45:26.467 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler [“http-nio-8080”]
07-Jul-2021 07:45:26.525 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1361] milliseconds
07-Jul-2021 07:45:26.642 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
07-Jul-2021 07:45:26.643 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.50]
07-Jul-2021 07:45:26.678 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“http-nio-8080”]
07-Jul-2021 07:45:26.698 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [173] milliseconds
^C07-Jul-2021 07:45:48.615 INFO [Thread-2] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler [“http-nio-8080”]
07-Jul-2021 07:45:48.620 INFO [Thread-2] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
07-Jul-2021 07:45:48.624 INFO [Thread-2] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler [“http-nio-8080”]
07-Jul-2021 07:45:48.673 INFO [Thread-2] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler [“http-nio-8080”]
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker rm tomcat
Error: No such container: tomcat
[root@VM-0-10-centos home]# docker rm 36ef696ea43d
Error: No such container: 36ef696ea43d
[root@VM-0-10-centos home]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Image is up to date for tomcat:9.0
docker.io/library/tomcat:9.0
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3344:8080 --name tomcat01
“docker run” requires at least 1 argument.
See ‘docker run --help’.

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Run a command in a new container
[root@VM-0-10-centos home]# docker run -d -p 3344:8080 --name tomcat01 tomcat
Unable to find image ‘tomcat:latest’ locally
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:latest
d9f1c48a362de5a5791ed5689990e66454ed5bd0343e570c1c45c6782bf428f7
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (2ff0a2e7fec2a463065c1479f05f8f1a1ade5234895c1821b923f09258910c42): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3344 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
docker: Error response from daemon: Conflict. The container name “/tomcat01” is already in use by container that name.
See ‘docker run --help’.
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
docker: Error response from daemon: Conflict. The container name “/tomcat01” is already in use by container “d9f1c48a362de5a5791ed5689990e66454ed5bd0343e570c1c45c6782bf428f7”. You have to remove (or rename) that container to be able to reuse that name.
See ‘docker run --help’.
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9f1c48a362d tomcat “catalina.sh run” 2 minutes ago Created tomcat01
d22002127f91 nginx “/docker-entrypoint.…” 27 minutes ago Exited (0) 9 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 2 hours ago Exited (0) 2 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Image is up to date for tomcat:latest
docker.io/library/tomcat:latest
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker rmi 36ef696ea43d
Error response from daemon: conflict: unable to delete 36ef696ea43d (must be forced) - image is referenced in multiple repositories
[root@VM-0-10-centos home]# docker rmi -f 36ef696ea43d
Untagged: tomcat:9.0
Untagged: tomcat:latest
Untagged: tomcat@sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Deleted: sha256:36ef696ea43d360827271a0d69475cb11fde0029d26fda66ea3204c116908597
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9f1c48a362d 36ef696ea43d “catalina.sh run” 6 minutes ago Created tomcat01
d22002127f91 nginx “/docker-entrypoint.…” 31 minutes ago Exited (0) 14 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 2 hours ago Exited (0) 2 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
0bc3020d05f1: Already exists
a110e5871660: Already exists
83d3c0fa203a: Already exists
a8fd09c11b02: Already exists
96ebf1506065: Already exists
b8bf70f9cc4d: Already exists
3f6da67b9e68: Already exists
257407776119: Already exists
7bd0a187fb92: Already exists
307fc4df04c9: Already exists
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:9.0
docker.io/library/tomcat:9.0
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
Unable to find image ‘tomcat:latest’ locally
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:latest
docker: Error response from daemon: Conflict. The container name “/tomcat01” is already in use by container “d9f1c48a362de5a5791ed5689990e66454ed5bd0343e570c1c45c6782bf428f7”. You have to remove (or rename) that container to be able to reuse that name.
See ‘docker run --help’.
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9f1c48a362d tomcat “catalina.sh run” 9 minutes ago Created tomcat01
d22002127f91 nginx “/docker-entrypoint.…” 34 minutes ago Exited (0) 17 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 2 hours ago Exited (0) 2 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker rm d9f1c48a362d
d9f1c48a362d
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d22002127f91 nginx “/docker-entrypoint.…” 35 minutes ago Exited (0) 17 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 2 hours ago Exited (0) 2 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
4bdb1efaea1b2f88503460cd232bcd49cfe32a875ade1c748574ab67b5e6e0d8
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (f749b61fd0ace46c96bea0e279716883c321268a3a36b05a359daea1191ef5e8): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4bdb1efaea1b tomcat “catalina.sh run” 19 seconds ago Created tomcat01
d22002127f91 nginx “/docker-entrypoint.…” 36 minutes ago Exited (0) 18 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 3 hours ago Exited (0) 3 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker rm 4bdb1efaea1b
4bdb1efaea1b
[root@VM-0-10-centos home]# docker run -d -p 3355:90 --name tomcat01 tomcat
9c796934244fd24032958fe085534557fb313dff9fd815d813ffbe997007bdae
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (099c0dc7ca5a7e6275b1a0a166387a44f6e60e5a11e5e60bb45edbfd13a4c750): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:90 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c796934244f tomcat “catalina.sh run” 12 seconds ago Created tomcat01
d22002127f91 nginx “/docker-entrypoint.…” 37 minutes ago Exited (0) 20 minutes ago nginx01
9b63c66abec4 centos “/bin/bash” 2 hours ago Exited (0) 2 hours ago trusting_chatelet
3b5a10f48c17 hello-world “/hello” 2 hours ago Exited (0) 2 hours ago vibrant_taussig
bed36fce284a hello-world “/hello” 3 hours ago Exited (0) 3 hours ago dreamy_dubinsky
ecc1ad123a83 hello-world “/hello” 6 hours ago Exited (0) 6 hours ago elegant_tu
[root@VM-0-10-centos home]# docker rm -f $(docker ps -aq)
9c796934244f
d22002127f91
9b63c66abec4
3b5a10f48c17
bed36fce284a
ecc1ad123a83
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
d6dd71efdd52391ae47e37256943e7cc1362d44ad9408e36b742c8a2cb4bd8ea
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (17325828549bc0a85ae40111baab0e79c2b63de6aa8007fca3f10b69163f4ef1): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6dd71efdd52 tomcat “catalina.sh run” 13 seconds ago Created tomcat01
[root@VM-0-10-centos home]# docker rm d6dd71efdd52
d6dd71efdd52
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker rmi 36ef696ea43d
Error response from daemon: conflict: unable to delete 36ef696ea43d (must be forced) - image is referenced in multiple repositories
[root@VM-0-10-centos home]# docker rmi 36ef696ea43d
Error response from daemon: conflict: unable to delete 36ef696ea43d (must be forced) - image is referenced in multiple repositories
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker rmi -f 36ef696ea43d
Untagged: tomcat:9.0
Untagged: tomcat:latest
Untagged: tomcat@sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Deleted: sha256:36ef696ea43d360827271a0d69475cb11fde0029d26fda66ea3204c116908597
Deleted: sha256:c7d10fdb2aa0f6e7e30fc102f7670a10fca4d43c267a62b235f9cf87d1240316
Deleted: sha256:5016ec30a812bdcfd69bc0410e4ba9ed4f6ced2dc203cc64a463703e5e3b1079
Deleted: sha256:40dcb5705131a22bd7ec2f674777fd7a3913a828931b9212d49c8427336f2881
Deleted: sha256:bf98377dda9fe02a12840057a6fed93e753a63262494b87231061a81b6ac4a54
Deleted: sha256:46b14ae98fd2e31957babb019d687dd1ac4f0a565096dc5805110817d391c568
Deleted: sha256:6b3b9060e6d4d0009f38adb7fa37077d33966dbf632f795f4dd997f5abdae64d
Deleted: sha256:33d9996f6196b7459c2fff2af3c499c293df089085845401bec2ebda281b86d8
Deleted: sha256:2e17f8770b4ad4ce56357edc8dea7329f376803e703201f45141d044634c20e3
Deleted: sha256:4311d44226850ccb1c676c541d5a8cbfaa8a8fbbcbce7470f63f73de3b095452
Deleted: sha256:4e006334a6fdea37622f72b21eb75fe1484fc4f20ce8b8526187d6f7bd90a6fe
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
0bc3020d05f1: Pull complete
a110e5871660: Pull complete
83d3c0fa203a: Pull complete
a8fd09c11b02: Pull complete
96ebf1506065: Pull complete
b8bf70f9cc4d: Pull complete
3f6da67b9e68: Pull complete
257407776119: Pull complete
7bd0a187fb92: Pull complete
307fc4df04c9: Pull complete
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:9.0
docker.io/library/tomcat:9.0
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
Unable to find image ‘tomcat:latest’ locally
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:latest
16ff15b406fb48588ee785ee6cd20788f09a48ee6b7575b31287b849208e2112
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (34dc6e9bb849a29877139e8adffe269a1e1d6cf2db6925366ea76c48278efd93): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
16ff15b406fb tomcat “catalina.sh run” 15 seconds ago Created tomcat01
[root@VM-0-10-centos home]# docker rm 16ff15b406fb
16ff15b406fb
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 12 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
797faf1211b4f91f9544d485083978d00a26510823d8adcaeb7cb4948b572c4f
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (67b42fb79a4708e51125ff02ee821461081f01b94b07785e47ae995cc97f1d87): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker pa -a
unknown shorthand flag: ‘a’ in -a
See ‘docker --help’.

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

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(s) 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 quit

Management Commands:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.5.1-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
scan* Docker Scan (Docker Inc., v0.8.0)
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container’s changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container’s filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container’s filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run ‘docker COMMAND --help’ for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
797faf1211b4 tomcat “catalina.sh run” 12 seconds ago Created tomcat01
[root@VM-0-10-centos home]# netstat -ntulp |grep 3355
[root@VM-0-10-centos home]# systemctl start firewalld
[root@VM-0-10-centos home]# firewall-cmd --zone=public --add-port=3355/tcp --permanent
success
[root@VM-0-10-centos home]# firewall-cmd --reload
success
[root@VM-0-10-centos home]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1343/sshd
[root@VM-0-10-centos home]# netstat -ntulp |grep 3355
[root@VM-0-10-centos home]# systemctl start firewalld
[root@VM-0-10-centos home]# firewall-cmd --zone=public --add-port=3355/tcp --permanent
Warning: ALREADY_ENABLED: 3355:tcp
success
[root@VM-0-10-centos home]# firewall-cmd --reload
success
[root@VM-0-10-centos home]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1343/sshd
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
797faf1211b4 tomcat “catalina.sh run” 3 minutes ago Created tomcat01
[root@VM-0-10-centos home]# docker exec -it tomcat01 /bin/bash
Error response from daemon: Container 797faf1211b4f91f9544d485083978d00a26510823d8adcaeb7cb4948b572c4f is not running
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
797faf1211b4 tomcat “catalina.sh run” 4 minutes ago Created tomcat01
[root@VM-0-10-centos home]# docker rm -f 797faf1211b4
797faf1211b4
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -it --rm 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
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
07-Jul-2021 08:18:28.172 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.50
07-Jul-2021 08:18:28.175 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 28 2021 08:46:44 UTC
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.50.0
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-1160.11.1.el7.x86_64
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-11
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.11+9
07-Jul-2021 08:18:28.180 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
07-Jul-2021 08:18:28.181 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
07-Jul-2021 08:18:28.181 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
07-Jul-2021 08:18:28.206 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
07-Jul-2021 08:18:28.207 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
07-Jul-2021 08:18:28.208 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
07-Jul-2021 08:18:28.208 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
07-Jul-2021 08:18:28.208 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
07-Jul-2021 08:18:28.208 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
07-Jul-2021 08:18:28.224 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.30] using APR version [1.6.5].
07-Jul-2021 08:18:28.224 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
07-Jul-2021 08:18:28.224 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
07-Jul-2021 08:18:28.237 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1d 10 Sep 2019]
07-Jul-2021 08:18:29.035 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler [“http-nio-8080”]
07-Jul-2021 08:18:29.109 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1394] milliseconds
07-Jul-2021 08:18:29.267 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
07-Jul-2021 08:18:29.267 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.50]
07-Jul-2021 08:18:29.289 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“http-nio-8080”]
07-Jul-2021 08:18:29.303 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [193] milliseconds
^C07-Jul-2021 08:18:32.274 INFO [Thread-2] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler [“http-nio-8080”]
07-Jul-2021 08:18:32.282 INFO [Thread-2] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
07-Jul-2021 08:18:32.286 INFO [Thread-2] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler [“http-nio-8080”]
07-Jul-2021 08:18:32.332 INFO [Thread-2] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler [“http-nio-8080”]
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker pull tomcat:9.0
^C
[root@VM-0-10-centos home]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Image is up to date for tomcat:latest
docker.io/library/tomcat:latest
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
8e1f41ca765e127b796eb486ba70c185b74b79ce7b31888d3f6b1abd0403e512
docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (6bf8d11e9538eebe585acc7069bfc376a11f8bc30ea9ea36f448bb144063d242): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3355 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8e1f41ca765e tomcat “catalina.sh run” 31 seconds ago Created tomcat01
[root@VM-0-10-centos home]# docker rm -f 8e1f41ca765e
8e1f41ca765e
[root@VM-0-10-centos home]# systemctl restart docker
[root@VM-0-10-centos home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 13 hours ago 133MB
tomcat 9.0 36ef696ea43d 4 days ago 667MB
tomcat latest 36ef696ea43d 4 days ago 667MB
mysql 5.7 09361feeb475 2 weeks ago 447MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos latest 300e315adb2f 7 months ago 209MB
[root@VM-0-10-centos home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
752b2470c5d561cfdb5898dd09fe539897dca7a517dd1845215a34842b2772d6
[root@VM-0-10-centos home]# docker exec -it tomcat01 /bin/bash
root@752b2470c5d5:/usr/local/tomcat# cd …
root@752b2470c5d5:/usr/local# ls
bin etc games include lib man openjdk-11 sbin share src tomcat
root@752b2470c5d5:/usr/local# cd webapp.dist
bash: cd: webapp.dist: No such file or directory
root@752b2470c5d5:/usr/local# cd tomcat
root@752b2470c5d5:/usr/local/tomcat# ls
BUILDING.txt LICENSE README.md RUNNING.txt conf logs temp webapps.dist
CONTRIBUTING.md NOTICE RELEASE-NOTES bin lib native-jni-lib webapps work
root@752b2470c5d5:/usr/local/tomcat# cd webapps.dist
root@752b2470c5d5:/usr/local/tomcat/webapps.dist# ls
ROOT docs examples host-manager manager
root@752b2470c5d5:/usr/local/tomcat/webapps.dist# cd …
root@752b2470c5d5:/usr/local/tomcat# cp webapps.dist/* webapps
cp: -r not specified; omitting directory ‘webapps.dist/ROOT’
cp: -r not specified; omitting directory ‘webapps.dist/docs’
cp: -r not specified; omitting directory ‘webapps.dist/examples’
cp: -r not specified; omitting directory ‘webapps.dist/host-manager’
cp: -r not specified; omitting directory ‘webapps.dist/manager’
root@752b2470c5d5:/usr/local/tomcat# cp -r webapps.dist/* webapps
root@752b2470c5d5:/usr/local/tomcat# cd webapps
root@752b2470c5d5:/usr/local/tomcat/webapps# ls
ROOT docs examples host-manager manager
root@752b2470c5d5:/usr/local/tomcat/webapps# cd…
bash: cd…: command not found
root@752b2470c5d5:/usr/local/tomcat/webapps# cd …
root@752b2470c5d5:/usr/local/tomcat# exit
exit
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
752b2470c5d5 tomcat “catalina.sh run” 6 minutes ago Up 6 minutes 0.0.0.0:3355->8080/tcp, :::3355->8080/tcp tomcat01
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
752b2470c5d5 tomcat “catalina.sh run” 6 minutes ago Up 6 minutes 0.0.0.0:3355->8080/tcp, :::3355->8080/tcp tomcat01
[root@VM-0-10-centos home]# docker run -d --name nginx01 -p 3344:80 nginx
175165c7930f70b51549cdbca9ac06f6bf63e55abdacc034b56f55a5f175089e
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
175165c7930f nginx “/docker-entrypoint.…” 12 seconds ago Up 11 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
752b2470c5d5 tomcat “catalina.sh run” 7 minutes ago Up 7 minutes 0.0.0.0:3355->8080/tcp, :::3355->8080/tcp tomcat01
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
175165c7930f nginx “/docker-entrypoint.…” 17 seconds ago Up 16 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
752b2470c5d5 tomcat “catalina.sh run” 7 minutes ago Up 7 minutes 0.0.0.0:3355->8080/tcp, :::3355->8080/tcp tomcat01
[root@VM-0-10-centos home]# docker stop 175165c7930f
175165c7930f
[root@VM-0-10-centos home]# docker stop 752b2470c5d5
d752b2470c5d5
[root@VM-0-10-centos home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-0-10-centos home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
175165c7930f nginx “/docker-entrypoint.…” 43 seconds ago Exited (0) 16 seconds ago nginx01
752b2470c5d5 tomcat “catalina.sh run” 8 minutes ago Exited (143) 6 seconds ago tomcat01

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天予不洗头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值