[root@localhost ~]# docker run -d -p 8080:8080 tomcat:8.0.18-jre8
mysql
查看是否已经启动mysql服务
[root@localhost ~]# ps -ef|grep mysql
root 9357 9256 0 19:35 pts/3 00:00:00 grep --color=auto mysql
挂载容器卷,防止数据丢失
[root@localhost ~]# docker run -d -p 3306:3306 --privileged=true -v /chet/mysql/log:/var/log/mysql
-v /chet/mysql/data:/var/lib/mysql
-v /chet/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root mysql
启动
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c28bc2c70c0d mysql "docker-entrypoint.s…" 50 seconds ago Up 49 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp vigorous_payne
7a0bbae8288d tomcat:8.0.18-jre8 "catalina.sh run" 26 hours ago Up 26 hours 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp strange_ellis
b21ce3d73a58 ubuntu "bash" 2 days ago Up 2 days u1
[root@localhost ~]# docker exec -it vigorous_payne /bin/bash
root@c28bc2c70c0d:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 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>