docker 常用软件安装 nginx mysql redis nextcloud

文章目录

      • nginx安装
      • mysql安装
      • redis
      • gitbook
      • jekins
      • nextcloud(个人云盘)
        • tomcat7(jdk7)

nginx安装

docker run -d --name nginx -p 80:80 -p 443:443 \
-v /root/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
-v /root/docker/nginx/conf/:/etc/nginx/conf.d/:ro \
-v /root/docker/nginx/html/:/usr/share/nginx/html/:ro \
-v /root/docker/nginx/log/:/var/log/nginx/:ro \
nginx

ps:前置操作参考 复制初始配置文件
docker run -d --name ng --rm nginx
docker cp ng:/etc/nginx/nginx.conf /root/docker/nginx/nginx.conf
docker cp ng:/etc/nginx/conf.d/ /root/docker/nginx/conf
docker cp ng:/usr/share/nginx/html/ /root/docker/nginx/html
docker cp ng:/var/log/nginx/ /root/docker/nginx/log

ps: /root/docker : /yourpath 自定义本地地址

mysql安装

docker run -d --name mysql -p 3306:3306 \
-v /root/docker/mysql/data:/var/lib/mysql \
-v /root/docker/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
-e TZ=Asia/Shanghai \
mysql:8.0

ps:前置操作参考 复制初始配置文件
docker run -d --name msql -e MYSQL_ROOT_PASSWORD=root --rm mysql
docker cp msql:/var/lib/mysql/ /root/docker/mysql/data
docker cp msql:/etc/mysql/conf.d/ /root/docker/mysql/conf
docker stop msql

ps:1251无法远程连接操作参考(mysql8)
docker exec -it mysql bash
mysql -uroot -p -h localhost
select host,user,plugin,authentication_string from mysql.user;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
flush privileges;


------------------------------------------------------------------------------
#mysql5.7
docker run -d --name mysql57 -p 3306:3306 \
-v /root/docker/mysql57/data:/var/lib/mysql \
-v /root/docker/mysql57/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
-e TZ=Asia/Shanghai \
mysql:5.7

docker run -d --name mysql -p 3306:3306 \
-v /Users/qinxq/docker/mysql57/data:/var/lib/mysql \
-v /Users/qinxq/docker/mysql57/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
mysql:5.7

ps:前置操作参考 复制初始配置文件
docker run -d --name msql -e MYSQL_ROOT_PASSWORD=root --rm mysql:5.7
docker cp msql:/var/lib/mysql/ /root/docker/mysql57/data
docker cp msql:/etc/mysql/conf.d/ /root/docker/mysql57/conf
docker stop msql

ps: /root/docker : /yourpath 自定义本地地址

-----------------------------------------------------------------------------
解决dockerMYSQL5.7版本sql_mode=only_full_group_by问题

docker exec -it mysql   /bin/bash
apt-get update
apt-get install vim
/etc/mysql/mysql.conf.d/mysqld.cnf或者my.cnf
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

解决too many connections 无法连接的问题
SHOW VARIABLES LIKE '%max_con%';
SET GLOBAL max_connections = 3000;


sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

redis

docker run -p 6379:6379 --name redis \
	-v /root/docker/redis/redis.conf:/etc/redis/redis.conf  \
	-v /root/docker/redis/data:/data \
	-d redis \
	redis-server /etc/redis/redis.conf \
	--appendonly yes \
	--requirepass "DEV_qin" 
	
	ps:
	 /root/docker : /yourpath 自定义本地地址
	 redis-server /etc/redis/redis.conf  以配置文件启动redis
	 appendonly yes 开启redis 持久化

gitbook

docker search -s 3 gitbook //查询gitbook镜像 -s stars
docker pull fellah/gitbook //拉取镜像
docker run \
	-v /root/docker/gitbook:/srv/gitbook \
	-v /root/docker/gitbook/html:/srv/html \
	fellah/gitbook gitbook build . /srv/html

ps: /root/docker/gitbook下需要有README.md和SUMMARY.md文件
ps: /root/docker : /yourpath 自定义本地地址

jekins

docker run -d -p 80:8080 -p 50000:50000 \
-v jenkins:/var/jenkins_home \
-v /etc/localtime:/etc/localtime 
--name jenkins docker.io/jenkins/jenkins

ps:
-d 后台运行镜像
-p 8080:8080  将镜像的8080端口映射到服务器的8080端口
-p 50000:50000  将镜像的50000端口映射到服务器的50000端口
-v jenkins:/var/jenkins_home  /var/jenkins_home目录为jenkins工作目录,我们将硬盘上的一个目录挂载到这个位置,方便后续更新镜像后继续使用原来的工作目录。
-v /etc/localtime:/etc/localtime  让容器使用和服务器同样的时间设置。
--name jenkins 给容器起一个别名

#从容器中获取到初始化密码
docker exec jenkins tail /var/jenkins_home/secrets/initialAdminPassword

nextcloud(个人云盘)

 docker run  -d --name nextcloud -p 8089:80 \
 -v /nfs/nextcloud:/var/www/html \
 nextcloud
 
 ps:
 /nfs/nextcloud : 容器数据映射本地地址
 nextcloud : 镜像名称

tomcat7(jdk7)

docker run -dt --name tomcat7 -p 8080:8080 \
-v /root/docker/tomcat:/home/user/tomcat7/webapps \
codenvy/jdk7_tomcat7

你可能感兴趣的:(docker,nginx,mysql)