#centos添加阿里源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum repolist #安装docker yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum makecache fast yum -y install docker-ce systemctl start docker #搜索镜像 docker search 名称 #下载镜像 docker pull 名称:版本 #查看本地镜像 docker images #查看后台 docker ps -a #安装MySQL docker run -p 3306:3306 \ -v /usr/share/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf \ -v /usr/share/docker/mysql/data:/var/lib/mysql \ --restart=always \ --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 \ --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower_case_table_names=1 #通过jre镜像创建一个容器启动一个springboot项目 docker run -p 8080:8080 \ -v /usr/share/docker/xxx:/usr/xxx \ --restart=always \ --name xxx -d fabletang/jre8-alpine:181 \ java -jar /usr/xxx/xxx.jar --server.port=8080 #安装nginx docker run \ -v /usr/share/docker/nginx/html:/usr/share/nginx/html \ -v /usr/share/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \ -v /usr/share/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf \ -v /usr/share/docker/nginx/logs:/var/log/nginx \ --net=host \ --restart=always \ --name nginx -d nginx 安装redis docker run -p 6379:6379 \ -v /usr/share/docker/redis/conf/redis.conf:/etc/redis/redis.conf \ -v /usr/share/docker/redis/data:/data \ --restart=always \ --name redis -d redis \ redis-server /etc/redis/redis.conf #安装wordpress docker run \ -p 1080:80 \ -p 1081:443 \ -e WORDPRESS_DB_HOST=127.0.0.1:3306 \ -e WORDPRESS_DB_USER=root \ -e WORDPRESS_DB_PASSWORD=123456 \ -v /usr/share/docker/wordpress:/var/www/html \ -v /usr/share/docker/nginx/cert:/etc/cert \ --restart=always \ --name wordpress -d wordpress #wordpress开启ssl a2enmod ssl #重启wordpress touch /usr/local/etc/php/conf.d/uploads.ini \ && echo "upload_max_filesize = 10M;" >> /usr/local/etc/php/conf.d/uploads.ini #/etc/apache2/sites-available下default-ssl.conf添加 SSLCertificateFile /etc/cert/ssl.pem SSLCertificateKeyFile /etc/cert/ssl.key #软链接路径 ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf 000-default.conf增加 <Directory "/var/www/html"> RewriteEngine on RewriteBase / # FORCE HTTPS RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] </Directory> #进入容器 docker exec -it tomcat bash #docker时区问题 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo "Asia/Shanghai" > /etc/timezone #更新docker中的源 mv /etc/apt/sources.list /etc/apt/sources.list.bak echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
发表回复