docker安装redis、rabbitmq、sentinel、nginx、tomcat、vue
创始人
2024-04-16 13:43:15
0

#一、redis安装
1、docker search redis 命令来查看可用版本:

2、取最新版的 Redis 镜像
docker pull redis:latest

3、查看本地镜像
docker images

4、运行容器
docker run -itd --name redis-test -p 6379:6379 redis
-p 6379:6379:映射容器服务的 6379 端口到宿主机的 6379 端口。外部可以直接通过宿主机ip:6379 访问到 Redis 的服务。

5、安装成功
最后我们可以通过 docker ps 命令查看容器的运行信息:

接着我们通过 redis-cli 连接测试使用 redis 服务。

docker exec -it redis-test /bin/bash

6、查看目录
ls

7、自启动
docker update --restart=always xxx

#二、安装rabbitmq

docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management

docker cp /root/ancen/mysql/my.cnf mysql-hw:/etc/mysql/my.cnf

#三、安装sentinel

1、 docker pull bladex/sentinel-dashboard

2、docker run --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard

ID:sentinel
PWD:sentinel

#四、安装nginx

nginx.conf配置文件

#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

1、docker pull nginx

2、mkdir -p /data/nginx/{conf,conf.d,html,logs}

3、创建 vim /data/nginx/conf/nginx.conf 配置文件

4、配置index.html欢迎页

docker run --name mynginx -d -p 80:80
-v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
-v /data/nginx/html:/usr/share/nginx/html
-v /data/nginx/logs:/var/log/nginx -d docker.io/nginx

–name nginx-test:容器名称。
-p 8080:80: 端口进行映射,将本地 8080 端口映射到容器内部的 80 端口。
-d nginx: 设置容器在在后台一直运行。

5、配好重启
docker restart mynginx

#五、安装tomcat

1、查询Tomcat镜像列表
docker search tomcat2、执行命令下载tomcat镜像
docker pull tomcat1、首先我们还是要查看一下目前正在运行状态的tomcat容器的信息(ID或者别名):
docker ps
2、通过docker stop实现容器停止关闭:
docker stop 22#挂载/root/ancen/tomcat/webapps目录,并运行容器命令如下 自启动
docker run --name tomcat-service -d -p 8080:8080 -v /root/ancen/tomcat/webapps:/usr/local/tomcat/webapps --restart=always tomcatdocker run -d -p 8081:8081 -p 8090:8090 --name tomcat:8 -v /usr/local/ancen/tomcat-netty:/usr/local/tomcat/webapps -v /usr/local/ancen/tomcat-netty:/usr/local/tomcat/logs -v /usr/local/ancen/tomcat-netty:/usr/local/tomcat/conf --restart=always tomcat:8自启动
docker update --restart=always xxx

#六、安装vue部署

nginx.conf文件

worker_processes auto;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;client_max_body_size   20m;server {listen       8081;server_name  150.158.156.225;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;try_files $uri $uri/ /index.html;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}
-------------------创建、编辑dockerfile文件---
touch Dockerfile
vim Dockerfile--------------------将文件拷入
FROM nginx
# 定义作者
MAINTAINER longdb
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/  /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
RUN echo 'echo init ok!!'//退出保存
esc  -->:wq------------------创建dockervue镜像
docker build -t dockervue .------------------启动容器 将dist文件从/usr/share/nginx/html挂载在/root/ancen/vue/下
docker run --name dockervue -d -p 80:80 -v /root/ancen/vue/dist:/usr/share/nginx/html  dockervue自启动
docker update --restart=always xxx

相关内容

热门资讯

喜欢穿一身黑的男生性格(喜欢穿... 今天百科达人给各位分享喜欢穿一身黑的男生性格的知识,其中也会对喜欢穿一身黑衣服的男人人好相处吗进行解...
发春是什么意思(思春和发春是什... 本篇文章极速百科给大家谈谈发春是什么意思,以及思春和发春是什么意思对应的知识点,希望对各位有所帮助,...
网络用语zl是什么意思(zl是... 今天给各位分享网络用语zl是什么意思的知识,其中也会对zl是啥意思是什么网络用语进行解释,如果能碰巧...
为什么酷狗音乐自己唱的歌不能下... 本篇文章极速百科小编给大家谈谈为什么酷狗音乐自己唱的歌不能下载到本地?,以及为什么酷狗下载的歌曲不是...
家里可以做假山养金鱼吗(假山能... 今天百科达人给各位分享家里可以做假山养金鱼吗的知识,其中也会对假山能放鱼缸里吗进行解释,如果能碰巧解...
华为下载未安装的文件去哪找(华... 今天百科达人给各位分享华为下载未安装的文件去哪找的知识,其中也会对华为下载未安装的文件去哪找到进行解...
四分五裂是什么生肖什么动物(四... 本篇文章极速百科小编给大家谈谈四分五裂是什么生肖什么动物,以及四分五裂打一生肖是什么对应的知识点,希...
怎么往应用助手里添加应用(应用... 今天百科达人给各位分享怎么往应用助手里添加应用的知识,其中也会对应用助手怎么添加微信进行解释,如果能...
客厅放八骏马摆件可以吗(家里摆... 今天给各位分享客厅放八骏马摆件可以吗的知识,其中也会对家里摆八骏马摆件好吗进行解释,如果能碰巧解决你...
苏州离哪个飞机场近(苏州离哪个... 本篇文章极速百科小编给大家谈谈苏州离哪个飞机场近,以及苏州离哪个飞机场近点对应的知识点,希望对各位有...