docker使用

安装tomcat 9

docker pull tomcat:9.0.56-jdk8-temurin-focal
docker run -d -p 8082:8080 --name my-tomcat 6b16c2a1d213
docker exec -it my-tomcat /bin/bash
cp -r webapps.dist/* webapps/

安装 guacamole

连接内部数据库
docker run --name some-guacd -d -p 4822:4822 guacamole/guacd
docker run --name some-guacamole --link some-guacd:guacd --link some-mysql:mysql -e MYSQL_DATABASE='guacamole_db' -e MYSQL_USER=guacamole -e MYSQL_PASSWORD=guacamole -d -p 172.16.10.184:8080:8080 guacamole/guacamole

http://172.16.10.184:8082/guacamole/#/

docker run --name some-guacamole --link some-guacd:guacd --link some-mysql:mysql -e MYSQL_DATABASE='guacamole_db' -e MYSQL_USER='root' -e MYSQL_PASSWORD='123456' -d -p 172.16.10.184:8080:8080 guacamole/guacamole


连接外部数据库
mysql以非docker方式运行,程序通过注入环境变量(连接地址、账号、密码)的方式连接本地数据库
docker run --name guacd -p 4822:4822 -d guacamole/guacd
docker run --name guacamole --link guacd -e MYSQL_HOSTNAME='10.0.19.143' -e MYSQL_PORT='3306' -e MYSQL_DATABASE='guacamole'  -e MYSQL_USER='guacamole' -e MYSQL_PASSWORD='guacamole'  -d -p 8082:8080 guacamole/guacamole



mysql -uroot -p
mysql> CREATE DATABASE guacamole_db;
mysql> CREATE USER 'guacamole'@'%' IDENTIFIED BY 'guacamole';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole'@'%';
mysql> FLUSH PRIVILEGES;
mysql> use guacamole_db;
mysql> source /root/initdb.sql;

firewall-cmd --zone=public --add-port=4822/tcp --permanent


docker run --name guacamole --link some-guacd:guacd \
    --link some-mysql:mysql         \
    -e MYSQL_DATABASE=guacamole_db \
    -e MYSQL_USER=root    \
    -e MYSQL_PASSWORD=123456 \
    -d -p 9090:8080 guacamole/guacamole

运行nginx

docker run -d -p 8082:80 --name nginx01 nginx:v1
docker cp nginx01:/usr/share/nginx/html /home/data/nginx/html
docker cp nginx01:/var/log/nginx /home/data/nginx/log
docker cp nginx01:/etc/nginx/conf.d/default.conf /home/data/nginx/conf
docker run -d -p 8082:80 \
	-v /home/data/nginx/log:/var/log/nginx \
	-v /home/data/nginx/html:/usr/share/nginx/html \
	-v /home/data/nginx/conf:/etc/nginx/conf.d \
	--name nginx02 nginx:v1

创建镜像
docker commit -a "auth" -c 'WORKDIR "/go"' -m "Commit Message" testgo2 centosgo:v4

posted @ 2024-02-22 13:17  windlog  阅读(13)  评论(0编辑  收藏  举报