欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

常见问题解决:Docker篇

程序员文章站 2022-06-14 17:28:30
...

1、Linux下安装Docker

安装Docker的前提是:内核版本必须是3.10及以上

# 查看内核版本
uname ‐r
# 安装docker
[[email protected] ~]# yum install docker
# 启动docker
[[email protected] ~]# systemctl start docker
# 查看docker启动状态
[[email protected] ~]# systemctl status docker
# 开启启动docker
[[email protected] ~]# systemctl enable docker
# 停止docker
[[email protected] ~]# systemctl stop docker

2、使用Docker安装Redis并使用Redis客户端

# 使用国内镜像加速
[[email protected] ~]# docker pull registry.docker‐cn.com/library/redis
[[email protected] ~]# docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
registry.docker-cn.com/library/redis   latest              0f55cf3661e9        12 days ago         95 MB
[[email protected] ~]# docker run -d -p 6379:6379 --name myredis 0f55cf3661e9
e0ee9b72fabfd936f4e46705c85dd849585aa46bf6a44f4627b7c461a3dc7b6f
[[email protected] ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
09e00d08dc5d        0f55cf3661e9        "docker-entrypoint..."   5 minutes ago       Up 5 minutes        0.0.0.0:6379->6379/tcp   myredis
# 启用Redis客户端
[[email protected] ~]# docker exec -it myredis redis-cli

3、使用Docker安装MySQL

[[email protected] scripts]# docker pull registry.cn-hangzhou.aliyuncs.com/hhzz/mysql
[[email protected] scripts]# docker images
REPOSITORY                                     TAG                 IMAGE ID            CREATED             SIZE
registry.cn-hangzhou.aliyuncs.com/hhzz/mysql   latest              1ba555be37dc        3 years ago         360 MB
[[email protected] scripts]# docker run -p 3306:3306 --name mysql  -e MYSQL_ROOT_PASSWORD=123456 -d 1ba555be37dc
2c99ad3a81ec0e155d92184673a3c52a244ce8430c87fd75740041d18b36f509