银河麒麟安装docker
一、安装
添加用户组和用户,非root启动docker
groupadd docker
useradd -m -g docker docker -s /sbin/nologin
添加权限
sudo tee /etc/sudoers.d/docker >/dev/null <<EOF
docker ALL=(ALL) NOPASSWD: ALL
EOF
安装
cd ~
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz
tar xzvf docker-20.10.6.tgz
cp docker/* /usr/bin/
rm docker-20.10.6.tgz -rf
rm docker -rf
二、配置docker启动
sudo tee /usr/lib/systemd/system/dockerd.service >/dev/null <<EOF
[Unit]
Description=Docker Daemon Service
[Service]
ExecStart=sudo /usr/bin/dockerd
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=docker daemon
User=docker
Group=docker
[Install]
WantedBy=multi-user.target
EOF
三、配置docker镜像源
mkdir /etc/docker
tee /etc/docker/daemon.json >/dev/null <<EOF
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
EOF
四、启动docker
systemctl enable dockerd
systemctl start dockerd
五、安装mysql
1.文件解析
/home/mysql/conf.d/docker.cnf 此文件默认为 [mysqld] 组,监听端口等配置在此。
/home/mysql/conf.d/mysql.cnf 此文件为客户端配置,配置组为[mysql]。
2.命令行
mkdir -p /home/mysql/conf.d
tee /home/mysql/conf.d/docker.cnf >/dev/null <<EOF
[mysqld]
skip-host-cache
skip-name-resolve
bind-address = 0.0.0.0
port = 3306
character-set-client-handshake = false
character-set-server = utf8mb4
init_connect='SET NAMES utf8mb4'
EOF
tee /home/mysql/conf.d/mysql.cnf >/dev/null <<EOF
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
EOF
运行 mysql
默认将配置文件放在 /home/mysql/conf.d
否则将 /home/mysql/database
docker run
--name mysql
-d
-p 3306:3306
-v /home/mysql/conf.d:/etc/mysql/conf.d
-v /home/mysql/database:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=mysql
-e MYSQL_USER=mysql
-e MYSQL_PASSWORD=mysql
mysql:8.0.25
更改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'
FLUSH PRIVILEGES;