centos7.5离线安装docker

centos7 安装

  • 默认设置安装即可
    https://jingyan.baidu.com/article/20095761d65c67cb0721b4a8.html

  • 解决Centos7安装后无法联网的问题
    https://www.cnblogs.com/zhi-leaf/p/5983470.html

  • 使用CentOS7 ISO镜像作为yum安装源(此步骤至关重要,一定要进行)
    https://blog.csdn.net/zhaoxusheng/article/details/71439693

  • 注意新建的配置文件在 /etc/yum.repos.d 内 将其他的配置文件都更改名称做备份存在

    [base]
    name=CentOS-$releasever-Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    baseurl=file:///mnt/cdrom
    enabled=1
    gpgcheck=0
    gpgkey=file:///mnt/cdrom/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
  • 需要将源清空重做缓存,而非update(yum [Errno 256] No more mirrors to try 解决方法 https://blog.csdn.net/weiguang1017/article/details/39007263)

	yum clean all
	yum makecache

安装vim(可省略)

yum install -y vim

离线安装mysql(可省略)

https://www.cnblogs.com/Orange42/p/8432185.html

1、卸载mariadb
	rpm -e --nodeps mariadb-libs

2、安装net-tools(安装server时会提示需要此工具)
	yum install -y net-tools

3、安装mysql
	mkdir mysqldir
	tar -xvf mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar -C ./mysqldir/
	cd mysqldir/
	rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm
	rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm
	rpm -ivh mysql-community-devel-5.7.23-1.el7.x86_64.rpm
	rpm -ivh mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm
	rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm
	rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm
	
4、配置mysql密码
	service mysqld stop
	vim /etc/my.cnf
	在其中添加以下内容
		`# Disabling symbolic-links is recommended to prevent assorted security risks
		skip-grant-tables     #添加这句话,这时候登入mysql就不需要密码
	symbolic-links=0`

	service mysqld start
	mysql -uroot -p  # 无需密码  enter即可

	在mysql中执行以下命令:
	flush privileges;  #更新权限
	set password for root@localhost = password('abcd@1234'); 
	flush privileges;
	exit;

	service mysqld stop # 停止mysql服务, 恢复mysql配置
	vim /etc/my.cnf     #修改配置文件,注释掉刚才添加的skip-grant-tables 
	service mysqld start
	此时即可登录了

5、设置mysql开机自启:
	systemctl enable mysqld

6、设置mysql允许访问
	进入mysql
	1、set global validate_password_policy=0;
	2、GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'abcd@1234' WITH GRANT OPTION;
	3、flush privileges;

7、防火墙开放mysql 3306端口
	firewall-cmd --zone=public --add-port=3306/tcp --permanent
	firewall-cmd --reload

安装docker和docker-compose(根据需要的版本下载)

http://blog.sina.com.cn/s/blog_3c7c794801030kya.html
1、yum install container-selinux-2.68-1.el7.noarch.rpm
2、yum install docker-ce-18.06.0.ce-3.el7.x86_64.rpm
3、systemctl start docker
4、通过命令docker version 查看docker版本,确认docker安装成功

安装docker-compose

  • 在可以联网的机器上按官方在线下载,之后在/usr/local/bin/下可以找到docker-compose,复制此文件到离线机器,同样放置在/usr/local/bin
  • sudo chmod 774 /usr/local/bin/docker-compose 添加执行权限

你可能感兴趣的:(docker,linux)