#### 下载镜像
打开网易镜像中心 需要登录的样子哦
dokcer官网 本人打不开
拉去镜像
docker pull hub.c.163.com/library/mysql:5.7
root@sheng-PC:/home/sheng/Desktop# docker pull hub.c.163.com/library/mysql:5.7
5.7: Pulling from library/mysql
42cb69312da9: Pull complete
e2cf5467c4b5: Pull complete
871ec0232f66: Pull complete
3c0ae7ec690d: Pull complete
d39b43089b70: Pull complete
aa0e7cb4b67c: Pull complete
738db9902d06: Pull complete
ae333863ac05: Pull complete
6d014992204a: Pull complete
09aeca0c9a82: Pull complete
0162083b2de0: Pull complete
Digest: sha256:10b4a255e03cce2eb12adfede34c99d86cc0e4d66f515f6bec92eb8c8c12bfef
Status: Downloaded newer image for hub.c.163.com/library/mysql:5.7
查看所有本地镜像
docker images
root@sheng-PC:/home/sheng/Desktop# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hub.c.163.com/library/mysql 5.7 9e64176cd8a2 22 months ago 407MB
创建并启动一个MySQL容器
docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d hub.c.163.com/library/mysql
root@sheng-PC:/home/sheng/Desktop# docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d hub.c.163.com/library/mysql
Unable to find image 'hub.c.163.com/library/mysql:latest' locally
latest: Pulling from library/mysql
42cb69312da9: Already exists
e2cf5467c4b5: Already exists
871ec0232f66: Already exists
3c0ae7ec690d: Already exists
d39b43089b70: Already exists
aa0e7cb4b67c: Already exists
738db9902d06: Already exists
ae333863ac05: Already exists
6d014992204a: Already exists
09aeca0c9a82: Already exists
0162083b2de0: Already exists
Digest: sha256:b2bce1a792237ac5df78877d583f34b09ab023a77130921a6bcce67ce2d24ff0
Status: Downloaded newer image for hub.c.163.com/library/mysql:latest
066e8a70027fc839ac9900c013b05dfc70223f4319a96a5c0d40b2487fff319a
参数说明下
- –name
:给新创建的容器命名,此处命名为pwc-mysql
- -e
:MYSQL_ROOT_PASSWORD
配置信息,此处配置mysql的root用户的登陆密码
- -p
:端口映射,映射主机3306端口到容器的3306端口
- -d
:成功启动容器后输出容器的完整ID
- 最后一个mysql
指的是mysql
镜像名字 【不明确看图吧!】
可能会出现问题解决方案
- 没有指定密码、或者端口这些的
-
- 直接`docker rm 容器ID`,查看容器
id
输入:docker ps
- 直接`docker rm 容器ID`,查看容器
查看容器运行状态
docker ps
root@sheng-PC:/home/sheng/Desktop# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
066e8a70027f hub.c.163.com/library/mysql "docker-entrypoint.s…" 6 seconds ago Up 4 seconds 0.0.0.0:3306->3306/tcp mysql