docker 之常见应用部署
https://hub.docker.com/ 查找需要的镜像和配置说明
一、Portainer
Portainer是Docker的图形化管理工具,提供状态显示面板、应用模板快速部署、容器镜像网络数据卷的基本操作(包括上传下载镜像,创建容器等操作)
拉取镜像
[root@yt yum.repos.d]# docker pull portainer/portainer Using default tag: latest latest: Pulling from portainer/portainer 94cfa856b2b1: Pull complete 49d59ee0881a: Pull complete a2300fd28637: Pull complete Digest: sha256:fb45b43738646048a0a0cc74fcee2865b69efde857e710126084ee5de9be0f3f Status: Downloaded newer image for portainer/portainer:latest docker.io/portainer/portainer:latest
查看镜像
[root@yt ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE portainer/portainer latest 580c0e4e98b0 9 months ago 79.1MB
创建数据卷用于持久化Portainer数据
[root@yt ~]# docker volume create portainer_data portainer_data
运行
[root@yt ~]# docker run -d -p 9000:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
142ecf88d17f9da25bdd6d809aa2e50ba20c2e21e6cf45bf7dedcdc5817e31ab
用宿主机9000
端口关联容器中的9000
端口,并给容器起名为portainer
restart=always是指docker重启的时候会同时重启
5、访问 iP:9000
创建用户
如果是单机版,直接选择Local,点击连接
二、mysql
拉取mysql,指定版本
[root@yt ~]# docker pull mysql:5.7.28 5.7.28: Pulling from library/mysql 804555ee0376: Pull complete c53bab458734: Pull complete ca9d72777f90: Pull complete 2d7aad6cb96e: Pull complete 8d6ca35c7908: Pull complete 6ddae009e760: Pull complete 327ae67bbe7b: Pull complete 31f1f8385b27: Pull complete a5a3ad97e819: Pull complete 48bede7828ac: Pull complete 380afa2e6973: Pull complete Digest: sha256:b38555e593300df225daea22aeb104eed79fc80d2f064fde1e16e1804d00d0fc Status: Downloaded newer image for mysql:5.7.28 docker.io/library/mysql:5.7.28
查看
[root@yt ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE portainer/portainer latest 580c0e4e98b0 9 months ago 79.1MB mysql 5.7.28 db39680b63ac 2 years ago 437MB
运行
[root@yt ~]# docker run -di --name mymysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql:5.7.28 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 34da9b18ace04e7c65ed959f673de4cb3d976f59e957c94a2f9ef933f6927714
-e MYSQL_ROOT_PASSWORD=密码 即root用户的密码
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 设置编码集
测试
三、Elasticsearch
Elasticsearch 是一个分布式的 RESTful 风格的搜索和数据分析引擎
拉取镜像
[root@yt ~]# docker pull docker.io/elasticsearch:6.7.2 6.7.2: Pulling from library/elasticsearch 8ba884070f61: Pull complete b331515ab671: Pull complete bcf2b1fa0e4a: Pull complete f7a17ff6a854: Pull complete 3c509982db17: Pull complete 268f1d6adb82: Pull complete 9e0e44f72b02: Pull complete Digest: sha256:59144dbc396225d13980bb801eac65c83f9862ea08a3c5bef932ca91e0eda84e Status: Downloaded newer image for elasticsearch:6.7.2 docker.io/library/elasticsearch:6.7.2
查看
[root@yt ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE portainer/portainer latest 580c0e4e98b0 9 months ago 79.1MB mysql 5.7.28 db39680b63ac 2 years ago 437MB elasticsearch 6.7.2 2982ba071059 2 years ago 863MB
运行
[root@yt ~]# docker run -d --name=myse -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.7.2
c1702f6daa4e70b27142eb96f8aec4c44a54a60dbef3811dd2ea76bbc731bfbb
-e "discovery.type=single-node" 设置为单节点
访问 IP:9200
四、elasticsearch head插件监控管理
拉取镜像
[root@yt ~]# docker pull mobz/elasticsearch-head:5 5: Pulling from mobz/elasticsearch-head 75a822cd7888: Pull complete 57de64c72267: Pull complete 4306be1e8943: Pull complete 871436ab7225: Pull complete 0110c26a367a: Pull complete 1f04fe713f1b: Pull complete 723bac39028e: Pull complete 7d8cb47f1c60: Pull complete 7328dcf65c42: Pull complete b451f2ccfb9a: Pull complete 304d5c28a4cf: Pull complete 4cf804850db1: Pull complete Digest: sha256:55a3c82dd4ba776e304b09308411edd85de0dc9719f9d97a2f33baa320223f34 Status: Downloaded newer image for mobz/elasticsearch-head:5 docker.io/mobz/elasticsearch-head:5
[root@yt ~]# docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5
755ef6b9e9eac132078845598fea9c1fc773758d615ba21124bffaa3f6a737c7
访问 IP:9100
配置跨域
[root@yt ~]# docker exec -it myse bash [root@c1702f6daa4e elasticsearch]# ls LICENSE.txt README.textile config lib modules NOTICE.txt bin data logs plugins [root@c1702f6daa4e elasticsearch]# cd config/ [root@c1702f6daa4e config]# ls elasticsearch.keystore log4j2.properties users elasticsearch.yml role_mapping.yml users_roles jvm.options roles.yml [root@c1702f6daa4e config]# cat elasticsearch.yml cluster.name: "docker-cluster" network.host: 0.0.0.0
[root@yt ~]# docker cp myse:/usr/share/elasticsearch/config/elasticsearch.yml ./
修改如下:cluster.name:自定义集群名称
network.host:当前es节点绑定的ip地址
http.cors.enabled:是否支持跨域,
http.cors.allow-origin:当设置允许跨域
[root@yt ~]# cat elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@yt ~]# docker cp elasticsearch.yml myse:/usr/share/elasticsearch/config/
重启
[root@yt ~]# docker restart myse
myse
[root@yt ~]# docker restart 755ef6b9e9eac132078845598fea9c1fc773758d615ba21124bffaa3f6a737c7
755ef6b9e9eac132078845598fea9c1fc773758d615ba21124bffaa3f6a737c7
再次连接
六、Portainer容器管理
对容器的操作,启动,停止.....
添加容器
访问:IP:8080