docker安装常用的服务脚本汇总

ubuntu 安装 docker

sudo apt-get remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-get install software-properties-common
sudo apt-get update
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get install docker-ce docker-ce-cli containerd.io
systemctl start docker
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
service docker restart
sudo docker version
systemctl enable docker.service

docker 安装 potainer

mkdir /home/volumes/portainer/data
chmod 777 /home/volumes/portainer/data
docker pull portainer/portainer
docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /home/volumes/portainer/data:/data portainer/portainer

docker 安装 mysql

mkdir /home/volumes/mysql
chmod 777 /home/volumes/mysql
docker pull mysql:5.7
docker run -d -p 3306:3306 --name mysql --privileged=true --restart=always -v /home/volumes/mysql/log:/var/log/mysql -v /home/volumes/mysql/data:/var/lib/mysql -v /home/volumes/mysql/conf:/etc/mysql/config.d -e MYSQL_ROOT_PASSWORD=wqp18322598 mysql:5.7

docker 安装 redis

mkdir /home/volumes/redis
mkdir /home/volumes/redis/conf
mkdir /home/volumes/redis/data
mkdir /home/volumes/redis/log
chmod 777 /home/volumes/redis
准备一个redis.conf配置文件上传到 /home/volumes/redis/conf 下
docker pull redis:latest
docker run -d -p 6379:6379 --name redis --restart=always -v /home/volumes/redis/data:/data -v /home/volumes/redis/conf/redis.conf:/etc/redis/redis.conf -v /home/volumes/redis/log:/var/log redis:latest redis-server /etc/redis/redis.conf

docker 安装 MinIO

mkdir /home/volumes/minio
mkdir /home/volumes/minio/data
mkdir /home/volumes/minio/config
chmod 777 /home/volumes/minio
docker pull minio/minio
docker run -p 9001:9001 -p 9090:9090 --name minio -d --restart=always -e "MINIO_ACCESS_KEY=admin" -e "MINIO_SECRET_KEY=admin123" -v /home/volumes/minio/data:/data -v /home/volumes/minio/config:/root/.minio minio/minio server /data --console-address ":9090" --address ":9001"

docker 安装 elasticsearch 和 kibana

mkdir /home/volumes/elasticsearch
mkdir /home/volumes/elasticsearch/config
mkdir /home/volumes/elasticsearch/data
mkdir /home/volumes/elasticsearch/plugins
echo "http.host: 0.0.0.0" >> /home/volumes/elasticsearch/config/elasticsearch.yml
chmod -R 777 /home/volumes/elasticsearch
docker pull elasticsearch:7.4.2
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /home/volumes/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/volumes/elasticsearch/data:/usr/share/elasticsearch/data -v /home/volumes/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.4.2
docker pull kibana:7.4.2
docker run --name kibana --restart=always -e "I18N_LOCALE=zh-CN" -e ELASTICSEARCH_HOSTS=http://宿主机_IP:9200 -p 5601:5601 -d kibana:7.4.2

docker 安装 nacos

mkdir /home/volumes/nacos
mkdir /home/volumes/nacos/logs/ 
mkdir /home/volumes/nacos/init.d/
chmod -R 777 /home/volumes/nacos
docker pull nacos/nacos-server
docker run -d -p 8848:8848 --env MODE=standalone --env PREFER_HOST_MODE=hostname  -v /home/volumes/nacos/init.d:/home/nacos/init.d -v /home/volumes/nacos/logs:/home/nacos/logs --name nacos nacos/nacos-server
docker exec -it nacos /bin/bash
cd conf/
vim application.properties

-------------------------------------------------------------------------------------------
##新增两行
nacos.core.auth.enabled=true
nacos.core.auth.enable.userAgentAuthWhite=false
 
##修改三行
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey01234567890123456789012345345678999987654901234567890123456789}
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:example}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:example}
-------------------------------------------------------------------------------------------

exit
docker restart nacos

docker 安装 jenkins

mkdir /home/volumes/jenkins
mkdir /home/volumes/jenkins/jenkins_home
chmod -R 777 /home/volumes/jenkins
docker pull jenkins/jenkins:lts
docker run -d --name jenkins --restart=always -p 8080:8080 -v /home/volumes/jenkins/jenkins_home:/var/jenkins_home jenkins/jenkins:lts

docker 安装 Nginx

mkdir /home/volumes/nginx
mkdir /home/volumes/nginx/log
chmod -R 777 /home/volumes/nginx
docker pull nginx
docker run --name nginx -p 80:80 -d nginx
docker cp nginx:/etc/nginx/nginx.conf /home/volumes/nginx/nginx.conf
docker cp nginx:/etc/nginx/conf.d  /home/volumes/nginx/
docker cp nginx:/usr/share/nginx/html  /home/volumes/nginx/
docker stop nginx
docker rm nginx
docker run -p 80:80 --name nginx --restart=always -v /home/volumes/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/volumes/nginx/conf.d:/etc/nginx/conf.d -v /home/volumes/nginx/log:/var/log/nginx -v /home/volumes/nginx/html:/usr/share/nginx/html -d nginx:latest

你可能感兴趣的:(docker,容器,运维)