Docker部署Nginx和Tomcat和MySql

Docker部署Nginx
# 搜索镜像 docker search nginx |
端口映射外网访问
进入nginx内部
[root@iZbp17g2ontiv6b4tu0incZ ~]# docker stop 66d211897c38
66d211897c38
[root@iZbp17g2ontiv6b4tu0incZ ~]# docker exec -it myNginx /bin/bash
Error response from daemon: Container 66d211897c38085f902f3d4ae3967b4330d5234290de8603ccf5b65d5db39026 is not running
[root@iZbp17g2ontiv6b4tu0incZ ~]# docker run -d --name flnginx -p 2580:80 nginx
3b3f6483fe4fc94b6b8d3ab1f5b72fcaccf4186a10fa675f02720948f0140fbc
[root@iZbp17g2ontiv6b4tu0incZ ~]# docker exec -it flnginx /bin/bash
root@3b3f6483fe4f:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@3b3f6483fe4f:/# cd /etc/nginx/
root@3b3f6483fe4f:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
Docker部署Tomcat
[root@iZbp17g2ontiv6b4tu0incZ ~]# docker images |
熟悉的界面出现了
Docker部署Mysql(容器数据卷挂载)
# 运行容器做数据挂载
docker run -d -p 3306:3306 -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --name mysqlTest mysql
远程连接测试

进入Mysql
[root@fl02 ~]# docker exec -it ac8fa5b5d731 /bin/bash
root@ac8fa5b5d731:/# mysql -uroot -p -h localhost
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
# 显示数据库正常
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| Test |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.01 sec)
mysql> use Test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+----------------+
| Tables_in_Test |
+----------------+
| test |
+----------------+
1 row in set (0.00 sec)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 风离の博客!











