MySQL部署
#搜索MySQL镜像
docker search mysql
#拉取MySQL镜像
docker pull mysql:5.6
#创建挂载目录
mkdir ~/mysql
cd ~/mysql
#创建容器
docker run -id \
-p 3306:3306 \
--name=c_mysql \
-v $PWD/conf:/etc/mysql/conf.d \
-v $PWD/data:/var/lib/mysql \
-v $PWD/logs:/logs \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:5.6
#进入容器
docker exec -it c_mysql
#尝试Navicat连接
...
Tomcat部署
#搜索Tomcat镜像
docker search tomcat
#拉取Tomcat镜像
docker pull tomcat
#创建挂载目录
mkdir ~/tomcat
cd ~/tomcat
#创建容器
docker run -id \
-p 8080:8080 \
--name=c_tomcat \
-v $PWD:/usr/local/tomcat/webapps \
tomcat
Nginx部署
#搜索Nginx镜像
docker search nginx
#拉取Nginx镜像
docker pull nginx
#创建挂载目录
mkdir ~/nginx
cd ~/nginx
#创建容器
docker run -id \
-p 80:80 \
--name=c_nginx \
-v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf \
-v $PWD/logs:/var/log/nginx \
-v $PWD/html:/usr/share/nginx/html \
nginx
提前在该文件写入如下内容$PWD/conf/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Redis部署
#搜索Redis镜像
docker search redis
#拉取Redis镜像
docker pull redis:5.0
#创建容器
docker run -id \
-p 6379:6379 \
--name=c_redis \
redis:5.0
网友评论