0


docker安装步骤

一、docker安装步骤

1、上传docker-20.10.18.tgz压缩包到服务器上任意路径

2、解压文件,生成docker文件

tar -zxvf docker-20.10.18.tgz

3、将解压出来的docker文件复制到 /usr/bin/ 目录下

cp docker/* /usr/bin/

4、进入/etc/systemd/system/目录,并创建docker.service文件

cd /etc/systemd/system/

touch docker.service

5、打开docker.service文件,粘贴下面框里的内容,注意ip改为现场的服务器ip

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[Service]

Type=notify

the default is not to use systemd for cgroups because the delegate issues still

exists and systemd currently does not support the cgroup feature set required

for containers run by docker

ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=192.168.200.128

ExecReload=/bin/kill -s HUP $MAINPID

Having non-zero Limit*s causes performance problems due to accounting overhead

in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

Uncomment TasksMax if your systemd version supports it.

Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

kill only the docker process, not all processes in the cgroup

KillMode=process

restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

[Install]

WantedBy=multi-user.target

6、给docker.service文件添加执行权限,命令如下

chmod 777 /etc/systemd/system/docker.service

7、重新加载配置文件(每次修改docker.service文件时都要重新加载下)

systemctl daemon-reload

8、启动docker服务

systemctl start docker

9、设置开机启动

systemctl enable docker.service

10、执行下面命令查看docker状态

systemctl status docker

出现下面这个界面就代表docker安装成功。

  • docker安装mysql
  1. 并上传mysql8.0.29.tar到服务器上(路径随便)
  2. 导入tar包到docker镜像中,执行下面脚本

docker load --input mysql8.0.29.tar

  1. 查看是否出现镜像

docker images

  1. 创建数据保存新目录(注意路径必须是最大空间目录)

mkdir -p /home/docker/mysql/{conf,logs,data,mysql-files}

  1. 在conf目录下创建my.cnf文件,文件内容如下

[mysqld]

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

secure_file_priv=/var/lib/mysql

  1. 创建mysql容器,启动Mysql新服务

Docker run --name newMysql --privileged=true --restart=always -v /home/docker/mysql/conf/:/etc/mysql/ -v /home/docker/mysql/logs:/logs -v /home/docker/mysql/data:/var/lib/mysql -v /home/docker/mysql/mysql-files:/var/lib/mysql-files -p 3307:3306 -e MYSQL_ROOT_PASSWORD=123 -d mysql:8.0.29

  1. 查看容器状态并进入容器

docker ps -a

docker exec -it 容器id /bin/bash

  1. 使用命令行进入mysql数据库改远程权限访问

mysql -uroot -p -h10.10.200.221 -P3306

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';

grant all privileges on . to 'root'@'%';

flush privileges;

标签: docker eureka 容器

本文转载自: https://blog.csdn.net/Guo09260830/article/details/140709184
版权归原作者 Guo09260830 所有, 如有侵权,请联系我们删除。

“docker安装步骤”的评论:

还没有评论