内网环境安装docker 并部署镜像

1. 内网部署 docker 参考连接 https://www.freesion.com/article/90971397099/

  1.1 版本选择 20.10.5  下载镜像地址:https://download.docker.com/linux/static/stable/x86_64/

 

  1.2 将下载好的文件上传到目标服务器 opt路径下 

    解压 tar -zxvf docker-20.10.5.tgz

 

  1.3  将解压好的 Docker 文件复制到 /usr/bin 目录下

    sudo cp docker/* /usr/bin/

     sudo cp docker.service /etc/systemd/system/ 

  1.4 在 /etc/systemd/system/ (/usr/lib/systemd/system/)目录下新增 docker.service 文件,将 docker 注册为服务

    linux 中 /etc/systemd/system和/usr/lib/systemd/system 的区别  默认路径和真实存放路径

  

[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=127.0.0.1
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

  1.5 为 docker.service 文件添加执行权限

    sudo chmod +x /etc/systemd/system/docker.service  

 

  1.6 重新加载配置文件

    sudo systemctl daemon-reload

  

  1.7 启动,设置开机启动,查看docker服务状态 

    sudo systemctl start docker

    sudo systemctl enable docker.service

    sudo systemctl status docker

    sudo docker ps 

2.外网拉去镜像 内网部署

  关于路径 技术镜像上传路径为opt; 挂载路径统一在 opt/docker ;

  2.1 docker 外网拉镜像打包,到内网安装镜像

 

  2.2 内网环境搭建docker具体步骤

 

  2.4 mysql 执行的相关命令

    准备技术镜像 打包镜像: docker save mysql:8.0.22 > mysql.tar

    上传到 公司服务器 opt路径下

    执行 docker load --input  mysql.tar

    docker images 查看 

    执行docker 启动命令: -e 是开启远程访问

docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=tsbx8888 --name mysql -e MYSQL_ROOT_HOST=% -v /home/docker/mysql/data:/var/lib/mysql -v /home/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /home/docker/mysql/mysql-files:/var/lib/mysql-files/ -v /home/docker/mysql/logs:/var/log/mysql mysql:8.0.22

    设置配置文件 lower_case_table_names = 1  表名比较的时候不区分大小写;将下边的问题 保存在 /home/docker/mysql/conf 路径下

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
 
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
# Custom config should go here
!includedir /etc/mysql/conf.d/
lower_case_table_names=1
my.conf

    docker ps 查看容器 通过Navicat 测试

  2.5 

  

 

 

 

 

3.公司环境考虑的问题,

  1.服务器的IP ,家里的电脑如果想要访问服务器  

    得有工具 和  服务器的地址 

 

 

4. 关于myql 大小写敏感问题

  配lower_case_table_names

  这

  lower_case_table_names=0 
  lower_case_table_names = 1 
  lower_case_table_names=2 
  unix,linuxlower_case_table_names 0 .Windows 1 .Mac OS X 2

 

 

 

 

 

 

 

 

 
 
 
posted @ 2022-04-14 10:11  BBS_自律  阅读(2917)  评论(0编辑  收藏  举报