【无标题】

1 环境搭建

docker官网:hub.docker.com
1 卸载系统之前的docker

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2 设置存储库

sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3 安装DOCKER引擎

sudo yum install docker-ce docker-ce-cli containerd.io

4 启动Docker.

sudo systemctl start docker

5 配置镜像加速(阿里云的控制台-镜像容器-镜像加速)

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://chqac97z.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

6.设置docker开机自启

sudo systemctl enable docker

【无标题】【无标题】

3.3 安装mysql

1 拉去mysql镜像

sudo docker pull mysql:8.0

2 启动mysql容器

# --name指定容器名字 -v目录挂载 -p指定端口映射  -e设置mysql参数 -d后台运行
sudo docker run --name mysql \
-v /usr/local/mysql/data:/var/lib/mysql \
-v /usr/local/mysql/conf:/etc/mysql/conf.d \
-v /usr/local/mysql/log:/var/log/mysql  \
-e MYSQL_ROOT_PASSWORD=root  \
-p 3306:3306 \
-d mysql:8.0

3 使用su - root(切换为root,这样就不用每次都sudo来赐予了)

su - root

4 进入mysql容器

docker exec -it 容器名称|容器id bin/bash

5.配置mysql的字符编码等

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqlId]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAME utf8'
character-set-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
上一篇:思科数据中心CCIE v3.0考试内容


下一篇:Linux服务器部署Web应用