docker安装redisrabbitmqsentinelnginxtomcatvue
Posted weixin_ancenhw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker安装redisrabbitmqsentinelnginxtomcatvue相关的知识,希望对你有一定的参考价值。
#一、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 tomcat
2、执行命令下载tomcat镜像
docker pull tomcat
1、首先我们还是要查看一下目前正在运行状态的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 tomcat
docker 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
以上是关于docker安装redisrabbitmqsentinelnginxtomcatvue的主要内容,如果未能解决你的问题,请参考以下文章