### docker启动相关命令 192.168.200.242中mysql、172.24.4.190中的oracle都是在docker中的。 #### 1. root账号进入宿主机; #### 2. 查看所有的docker镜像; - 查看所有的docker镜像:`docker ps -a`; ```shell [root@dftnode2 mysql]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e3b817ca00ba mysqlsrv:0.0.1 "/bin/bash" 22 months ago Up 2 minutes 8003/tcp, 0.0.0.0:3315->22/tcp, 0.0.0.0:2060->3306/tcp mysqlsrv [root@dftnode2 mysql]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e23a33317df3 oracle:12.0 "/entrypoint.sh /bin/" 16 months ago Exited (1) 5 days ago 0.0.0.0:1521->1521/tcp, 0.0.0.0:3307->22/tcp, 0.0.0.0:18080->8080/tcp orasrv dfa2abc019b7 pqsql:0.0.1 "/bin/bash" 16 months ago Exited (1) 5 days ago 2099/tcp, 6064-6065/tcp, 8002/tcp, 0.0.0.0:5432->5432/tcp, 0.0.0.0:3309->22/tcp pqsql 42391561a0c3 tomcat:7.0.73 "/bin/bash" 22 months ago Exited (1) 5 days ago 2099/tcp, 8002/tcp, 0.0.0.0:3161->3161/tcp, 0.0.0.0:3318->22/tcp zookeeper e3b817ca00ba mysqlsrv:0.0.1 "/bin/bash" 22 months ago Up 2 minutes 8003/tcp, 0.0.0.0:3315->22/tcp, 0.0.0.0:2060->3306/tcp mysqlsrv bd879231d9ec datasharelib:0.0.4 "/bin/bash" 23 months ago Exited (1) 5 days ago 8003/tcp, 8007/tcp, 0.0.0.0:8407->8407/tcp, 0.0.0.0:2248->22/tcp datasharelib 29950f9d4aee onewindow:0.0.4 "/bin/bash" 23 months ago Exited (1) 5 days ago onewindowzs f8271b41cf72 materialcatalog:0.0.4 "/bin/bash" 23 months ago Exited (1) 5 days ago 8003/tcp, 8005/tcp, 0.0.0.0:8405->8405/tcp, 0.0.0.0:2245->22/tcp materialcatalogzs eb36612391f1 mysql:5.7.22.2 "/bin/bash" 23 months ago Exited (137) About a minute ago mysqlsrvzs ``` - 查看已经启动的docker镜像,`docker ps`。 #### 3. 启动对应的docker镜像: 命令:`docker start #镜像id#` #### 4. 进入docker容器 > 注意:建议通过容器启动后的端口进入,不建议通过此命令方法进入。 命令:`docker attach #镜像id#` #### 5、做你想做的操作 比如数据库启动、tomcat启动 #### 6、退出当前容器 快捷键:`crtl`+`p`+`q` #### 7、其他:庄仁峰提供 > 第二种docker进入和退出命令 - 进入:docker exec -it #镜像id#` bash - 退出:exit