1、帮助命令
docker version # 显示docker的基本信息
docker info # 系统信息,镜像和容器的数量
docker 命令 --help # 全部信息
2、 镜像命令
命令 | 作用 |
---|---|
docker images | 查看所有本地主机上的镜像 |
docker search | 搜索仓库中的镜像,相当于网页搜索 |
docker pull | 下载镜像 |
docker rmi | 删除镜像 |
2.1、docker images
查看所有本地主机上的镜像
[root@localhost ~]# docker images
Options:
-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 numeric IDs
2.2、 docker search
搜索仓库中的镜像,相当于网页搜索
docker search mysql
2.3、 docker pull
下载镜像
docker pull mysql # 下载mysql镜像,default tag,默认最新版latest
下载指定版本
先在docker hup上搜索mysql
docker pull mysql:5.7
docker images
此时查看镜像,可以看到新下载的两个
2.4、 docker rmi
删除经镜像
docker rmi -f 镜像id
# 删除多个 用空格分隔id
docker rmi -f id id id
# 删除所有
docker rmi -f $(docker images -aq) # images -aq就是查所有镜像id,从而递归删除
3、 容器命令
docker pull centos
3.1、 新建容器并启动
docker run [可选参数] image
# 参数说明
--name=“Name” # 容器名字,用于区分容器
-d 后台方式运行
-it 使用交互方式运行,进入容器查看内容
-p 指定容器的端口 如-p 8080::8080
-p ip:主机端口:容器端口
-p 主机端口:容器端口
-p 容器端口
-P 随机指定端口
# 进入
docker run -it centos /bin/bash
# 查看目录
ls
# 退出
exit
主机名不一样
3.2、 查看运行的容器
# 查看正在运行的容器
docker ps
# 查看曾经运行的容器
docker ps -a
# 显示最近创建的容器,设置显示个数
docker ps -a - n=?
# 只显示容器的编号
docker ps -aq
3.3、 退出容器
# 容器停止退出
exit
# 容器不停止退出 注意必须在英文输入法下,中文输入法不行
Ctrl + P + Q
[root@localhost ~]# docker run -it centos /bin/bash
[root@c977bd6638aa /]# [root@localhost ~]# docker ps ## 这里Ctrl + P + Q
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c977bd6638aa centos "/bin/bash" About a minute ago Up About a minute zealous_boyd
[root@localhost ~]# docker exec -it c977bd6638aa /bin/bash ## 再次进入
[root@c977bd6638aa /]# exit ##停止并推出
exit
[root@localhost ~]#
3.4、 删除容器
# 删除指定容器 不能删除正在运行的容器,如果强制删除 rm -f
docker rm 容器id
# 删除所有容器
docker rm -f $(docker ps -aq)
# 删除所有容器
docker ps -a -q|xargs docker rm
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c977bd6638aa centos "/bin/bash" 6 minutes ago Up 6 minutes zealous_boyd
3e2e96e5a71f centos "/bin/bash" 13 minutes ago Exited (0) 13 minutes ago boring_vaughan
647210e56098 centos "/bin/bash" 15 minutes ago Exited (0) 14 minutes ago objective_kilby
273aaf03a722 bf756fb1ae65 "/hello" 22 hours ago Exited (0) 22 hours ago competent_colden
[root@localhost ~]# docker rm 273aaf03a722
273aaf03a722
[root@localhost ~]# docker rm c977bd6638aa ##不能删除正在运行的容器
Error response from daemon: You cannot remove a running container c977bd6638aad432f29b42dfce4f8dfaed924fdd2fa268c6e2888c9d4bdb2930. Stop the container before attempting removal or force remove
[root@localhost ~]#
删除全部容器
4、查看日志
docker logs
docker logs -f -t --tail n 【容器id】
[root@localhost ~]# docker logs --help
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
--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:37) or relative (e.g. 42m for 42 minutes)
[root@localhost ~]#
# 运行一个centos
[root@localhost ~]# docker run -it centos /bin/bash
[root@d4e5c988112e /]# [root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4e5c988112e centos "/bin/bash" 31 seconds ago Up 30 seconds laughing_nobel
# 查看日志,什么都没有
[root@localhost ~]# docker logs -f -t --tail 10 d4e5c988112e
^C
#运行centos里面加个脚本
[root@localhost ~]# docker run -d centos /bin/sh -c "while true;do echo liang;sleep 1;done"
77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
77f7f6ce6f3b centos "/bin/sh -c 'while t…" 8 seconds ago Up 8 seconds kind_wozniak
d4e5c988112e centos "/bin/bash" 2 minutes ago Up 2 minutes laughing_nobel
[root@localhost ~]# docker ps -f -t --tail 10 77f7f6ce6f3b
invalid argument "-t" for "-f, --filter" flag: bad format of filter (expected name=value)
See 'docker ps --help'.
# 查看日志 发现隔一秒打印一条
[root@localhost ~]# docker logs -f -t --tail 10 77f7f6ce6f3b
2020-09-02T07:41:34.927974597Z liang
2020-09-02T07:41:35.934079719Z liang
2020-09-02T07:41:36.937165070Z liang
2020-09-02T07:41:37.940856606Z liang
2020-09-02T07:41:38.944088141Z liang
2020-09-02T07:41:39.946024478Z liang
2020-09-02T07:41:40.950709060Z liang
2020-09-02T07:41:41.952260493Z liang
2020-09-02T07:41:42.954826758Z liang
2020-09-02T07:41:43.957949659Z liang
2020-09-02T07:41:44.962295725Z liang
2020-09-02T07:41:45.965976271Z liang
2020-09-02T07:41:46.967958140Z liang
2020-09-02T07:41:47.969930635Z liang
2020-09-02T07:41:48.974646561Z liang
2020-09-02T07:41:49.977115048Z liang
2020-09-02T07:41:50.981126518Z liang
2020-09-02T07:41:51.983597001Z liang
5、 查看正在运行的容器信息
docker inspect 【容器id】
[root@localhost ~]# docker inspect 77f7f6ce6f3b
[
{
//容器的完整id
"Id": "77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020",
//创建时间
"Created": "2020-09-02T07:40:58.436567445Z",
//脚本位置
"Path": "/bin/sh",
//运行的脚本
"Args": [
"-c",
"while true;do echo liang;sleep 1;done"
],
"State": {
"Status": "running", // 状态,正在运行
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 5594, // 父进程id
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-09-02T07:40:58.770032031Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
// 来源镜像
"Image": "sha256:0d120b6ccaa8c5e149176798b3501d4dd1885f961922497cd0abef155c869566",
"ResolvConfPath": "/var/lib/docker/containers/77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020/hostname",
"HostsPath": "/var/lib/docker/containers/77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020/hosts",
"LogPath": "/var/lib/docker/containers/77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020/77f7f6ce6f3b5021bbb5ccc64c684de3451f2b0033470bc37e7169c0a0026020-json.log",
"Name": "/kind_wozniak",
"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,
"Capabilities": null,
"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/ededbe99cc03c4ca97dfae305a69ab581d89878c69ac6444bb33a99e24ff43cf-init/diff:/var/lib/docker/overlay2/d2d58ee9da9fa5949322be1ac0d84fe115f5d1e0d70f1eb04a3f783e50f05487/diff",
"MergedDir": "/var/lib/docker/overlay2/ededbe99cc03c4ca97dfae305a69ab581d89878c69ac6444bb33a99e24ff43cf/merged",
"UpperDir": "/var/lib/docker/overlay2/ededbe99cc03c4ca97dfae305a69ab581d89878c69ac6444bb33a99e24ff43cf/diff",
"WorkDir": "/var/lib/docker/overlay2/ededbe99cc03c4ca97dfae305a69ab581d89878c69ac6444bb33a99e24ff43cf/work"
},
"Name": "overlay2"
},
// 挂载
"Mounts": [],
# 基本配置
"Config": {
"Hostname": "77f7f6ce6f3b",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
// 基本环境变量,这里没有Java
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
// 基本命令
"Cmd": [
"/bin/sh",
"-c",
"while true;do echo liang;sleep 1;done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20200809",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS"
}
},
// 网卡,比如现在用的是桥接的网卡
"NetworkSettings": {
"Bridge": "",
"SandboxID": "e72dd4dc3f31fd173c17b343e3e8a9b9dbe7e2842fea3798a033e29ab5408824",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/e72dd4dc3f31",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "de4a3a2b8c5984f4bfe28c52cf617f1abe31398e6d031363cc7335bc021ea7ec",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "a55affbb52bbda4223b1ab0b8661c0faeeb4d583eb28feea57e77178b09963f8",
"EndpointID": "de4a3a2b8c5984f4bfe28c52cf617f1abe31398e6d031363cc7335bc021ea7ec",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]
[root@localhost ~]#
# 停止正在疯狂输出的那个容器
[root@localhost ~]# docker stop 77f7f6ce6f3b
77f7f6ce6f3b
6、 进入当前正在运行的容器
6.1、docker exec -it 容器id bashSHELL
# 我们通常容器都是使用后台方式运行的
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4e5c988112e centos "/bin/bash" 31 minutes ago Up 31 minutes laughing_nobel
[root@localhost ~]# docker exec -it d4e5c988112e /bin/bash
[root@d4e5c988112e /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@d4e5c988112e /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 07:38 pts/0 00:00:00 /bin/bash
root 14 0 0 08:11 pts/1 00:00:00 /bin/bash
root 28 14 0 08:12 pts/1 00:00:00 ps -ef
[root@d4e5c988112e /]# exit
exit
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4e5c988112e centos "/bin/bash" 33 minutes ago Up 33 minutes laughing_nobel
[root@localhost ~]#
6.2、docker attach 容器id
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4e5c988112e centos "/bin/bash" 33 minutes ago Up 33 minutes laughing_nobel
[root@localhost ~]# docker attach d4e5c988112e
[root@d4e5c988112e /]#
区别:
docker exec :进入容器后开启一个新的终端,可以在里面操作(常用)
docker attach:进入容器正在执行的终端,不会启动新的进程
7、 从容器内拷贝文件到主机上
# 运行
[root@localhost ~]# docker run -it centos
# ctrl P Q 不关闭退出,查看
[root@10440710b9f4 /]# [root@localhost ~]# cd /home
# 查看主机home下无文件 test.java文件
[root@localhost home]# ll
total 4
drwx------. 15 liang liang 4096 Aug 18 16:17 liang
[root@localhost home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10440710b9f4 centos
#进入正在运行的容器
[root@localhost home]# docker attach 10440710b9f4
#进入容器home目录
[root@10440710b9f4 /]# cd /home
# 在目录中创建java文件
[root@10440710b9f4 home]# touch test.java
# 退出并停止容器
[root@10440710b9f4 home]# exit
exit
# 查看现在运行的容器
[root@localhost home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost home]#
# 容器虽然被停止,但是数据都会保留
[root@localhost home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10440710b9f4 centos "/bin/bash" 5 minutes ago Exited (0) 37 seconds ago jovial_panini
77f7f6ce6f3b centos "/bin/sh -c 'while t…" 47 minutes ago Exited (137) 27 minutes ago kind_wozniak
d4e5c988112e centos "/bin/bash" 49 minutes ago Exited (127) 6 minutes ago laughing_nobel
[root@localhost home]#
# 容器数据拷贝到主机
[root@localhost home]# docker cp 10440710b9f4:/home/test.java /home
[root@localhost home]# ll
total 4
drwx------. 15 liang liang 4096 Aug 18 16:17 liang
-rw-r--r--. 1 root root 0 Sep 2 16:27 test.java
[root@localhost home]
# 拷贝是一个手动过程,未来我们使用 -v 卷的技术,可以实现自动同步 /home /home
8、 查看内容占用
docker stats
总结
[root@localhost home]# 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:
builder Manage builds
config Manage Docker configs
container Manage containers
context Manage contexts
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
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.
[root@localhost home]#
练习
部署nginx
#拉取nginx镜像
[root@localhost home]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
bf5952930446: Pull complete
cb9a6de05e5a: Pull complete
9513ea0afb93: Pull complete
b49ea07d2e93: Pull complete
a5e4a503d449: Pull complete
Digest: sha256:b0ad43f7ee5edbc0effbc14645ae7055e21bc1973aee5150745632a24a752661
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
#查看镜像
[root@localhost home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4bb46517cac3 2 weeks ago 133MB
centos latest 0d120b6ccaa8 3 weeks ago 215MB
[root@localhost home]
#运行
#-d 后台运行 --name指定名字 -p 暴露端口 宿主机端口:容器内部端口
[root@localhost home]# docker run -d --name nginx01 -p 8081:80 nginx
bcd07e34207509602c8dcbe6c0a2f71181a973c50dab7767460b4bf582189d6c
[root@localhost home]#
#访问
[root@localhost home]# curl localhost:8081
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@localhost home]#
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bcd07e342075 nginx "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 0.0.0.0:8081->80/tcp nginx01
#进入nginx
[root@localhost ~]# docker exec -it nginx01 /bin/bash
#查一下nginx在哪
root@bcd07e342075:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
#在这个位置
root@bcd07e342075:/# cd /etc/nginx/
root@bcd07e342075:/etc/nginx# ls
conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf
# 退出
root@bcd07e342075:/etc/nginx# exit
exit
# 停止
[root@localhost ~]# docker stop bcd07e342075
bcd07e342075
[root@localhost ~]#
部署tomcat
docker pull tomcat:9.0
# 启动运行,应该加上版本号
[root@localhost ~]# docker run -d -p 8082:8080 --name tomcat01 tomcat:9.0
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70af2ef3e3e4 tomcat:9.0 "catalina.sh run" 52 seconds ago Up 51 seconds 0.0.0.0:8082->8080/tcp tomcat01
[root@localhost ~]#
#进入容器
docker exec -it tomcat01 /bin/bash
部署es
# es 暴露的端口很多
# es 十分耗内存
# es 的数据一般需要放置到安全目录!挂载
# 启动 elasticsearch
$ docker run -d --name elasticsearch01 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
# 查看内存占用情况
docker stats
可视化
Docker图像化界面管理工具,提供一个后台面板供我们操作!
docker run -d -p 8088:9000 --restart=always -v /var/run/docker.sock:/var/run/docker --privileged=true portainer/portainer
访问http://192.168.8.150:8088/
输入用户名密码
"catalina.sh run" 52 seconds ago Up 51 seconds 0.0.0.0:8082->8080/tcp tomcat01
[root@localhost ~]#
#进入容器
docker exec -it tomcat01 /bin/bash
[外链图片转存中...(img-oZgWoJrw-1599040206929)]
[外链图片转存中...(img-sbVToZDY-1599040206929)]
### 部署es
[外链图片转存中...(img-txYtmde6-1599040206930)]
```shell
# es 暴露的端口很多
# es 十分耗内存
# es 的数据一般需要放置到安全目录!挂载
# 启动 elasticsearch
$ docker run -d --name elasticsearch01 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
# 查看内存占用情况
docker stats
[外链图片转存中…(img-TCtZCThb-1599040206930)]
可视化
Docker图像化界面管理工具,提供一个后台面板供我们操作!
docker run -d -p 8088:9000 --restart=always -v /var/run/docker.sock:/var/run/docker --privileged=true portainer/portainer
访问http://192.168.8.150:8088/
输入用户名密码