docker啟動一些開發軟體

CoderCoding發表於2024-03-10

yum install docker

前置條件:系統為centos7.x

----docker啟動時掛載本地路徑-------
--------這樣做的好處就是日誌和容器app都是存本地,不會在映象重啟後,重置容器中的東西------------

docker pull tomcat

docker run --name tomcat -itd --rm -p 8080:8080 -v /usr/local/tomcat/webapps:/usr/local/tomcat/webapps -v /usr/local/tomcat/logs:/usr/local/tomcat/logs tomcat

--------------------------------------------------------------------------------------

1.docker pull nginx
2.docker run -d --name nginx00 -p 80:80 nginx
3.建立nginx本地檔案對映目錄
cd /usr/local/nginx
mkdir html
mkdir logs
docker container cp nginx00:/etc/nginx .
mv nginx conf
4.停止原來的容器
docker stop nginx00 #停止
docker rm nginx00 #刪除
docker ps -a #看看是不是沒了
5.docker run -d -p 80:80 --name nginx01 -v /usr/local/nginx/html:/usr/share/nginx/html -v /usr/local/nginx/conf:/etc/nginx -v /usr/local/nginx/logs:/var/log/nginx nginx

6.以上黃色去背景位置為本地,html靜態檔案放到該目錄下


--------docker 掛載postgresql---------------

docker run -it --name postgres --restart always -e POSTGRES_PASSWORD='abc123' -e ALLOW_IP_RANGE=0.0.0.0/0 -v /usr/local/postgres/:/var/lib/postgresql -p 5432:5432 -d postgres

--------docker 掛載mysql---------

1.docker run -p 3306:3306 -v /usr/local/mysql/conf/conf.d:/etc/mysql/conf.d -v /usr/local/mysql/data:/var/lib/mysql -v /usr/local/mysql/logs:/logs -e MYSQL_ROOT_PASSWORD=abc123 -e TZ=Asia/Shanghai --name mysql -d mysql:latest

2.docker exec -it mysql /bin/bash

3.mysql -uroot -p

4.ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'abc123';

5.flush privileges;

--------docker 掛載redis---------
docker run --name redis -d -p 6379:6379 -v /usr/local/redis/data:/data redis

相關文章