一、离线安装docker
1、下载离线包
https://link.zhihu.com/?target=https%3A//download.docker.com/linux/static/stable/x86_64/
docker-18.09.8.tgz
2、安装docker
# 复制docker-18.09.8.tgz到 /usr/bin下(usr/bin是环境变量目录,在路径下可以直接运行docker命令)
# 解压
tar xvf docker-18.09.8.tgz
# ls -l docker
cp docker/* /usr/bin
# rm -rf docker docker-18.09.8.tgz
配置docker服务
# vim /etc/systemd/system/docker.service
# 添加
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
赋执行权限
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
3. docker 命令
# 开机启动
systemctl enable docker.service
# 启动docker
systemctl start docker
# docker状态
systemctl status docker
# 重启docker服务
systemctl restart docker
二、docker-compose 离线安装
1. 下载离线包
- 下载离线包
https://github.com/docker/compose/releases
- 下载的最新版本(这里要展开才能看到)
docker-compose-linux-x86_64
2. 安装docker-compose
- 上传安装包
# 改名为docker-compose 复制到 /usr/local/bin/下
cp -f ./docker-compose-linux-x86_64 /usr/local/bin/docker-compose
# 赋执行权限
chmod +x /usr/local/bin/docker-compose
三、 docker 离线镜像
1、在有网络的环境下下载镜像
# redis 镜像
docker pull redis:5.0.14
2、导出镜像
docker save redis:5.0.14 -o redis5014.tar
2、上传离线环境导入镜像
docker load -i redis5014.tar
3、查看镜像
docker images
4、创建redis管理目录,方便后期管理
mkdir data
5、编辑redis.conf配置文件
vim redis.conf
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.
################################## INCLUDES ###################################
# Include one or more other config files here. This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings. Include files can include
# other files, so use this wisely.
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf
################################## MODULES #####################################
# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so
################################## NETWORK #####################################
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.1