离线安装docker-compose

Posted 星海流浪人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了离线安装docker-compose相关的知识,希望对你有一定的参考价值。

1.github下载版本

https://github.com/docker/compose/releases

 

2.解压

 

 

3. 移到指定目录

mv docker-compose-linux-x86_64 /usr/local/bin/


//修改文件名
 mv docker-compose-linux-x86_64 docker-compose

//授权
sudo chmod +x /usr/local/bin/docker-compose

//查看安装是否成功
docker-compose -v

 

shell离线安装docker

首先要准备离线安装包

1.docker官网下载

2.docker-compose gitbub官网下载

3.我的docker-compose

install-docker.sh

#!/bin/sh

usage(){
  echo "Usage: $0 FILE_NAME_DOCKER_CE_TAR_GZ"
  echo "       $0 docker-18.09.0.tgz"
  echo "Get docker-ce binary from: https://download.docker.com/linux/static/stable/x86_64/"
  echo "eg: wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.0.tgz"
  echo ""
}
SYSTEMDDIR=/usr/lib/systemd/system
SERVICEFILE=docker.service
DOCKERDIR=/usr/bin
DOCKERBIN=docker
SERVICENAME=docker

if [ $# -ne 1 ]; then
  usage
  exit 1
else
  FILETARGZ="$1"
fi

if [ ! -f ${FILETARGZ} ]; then
  echo "Docker binary tgz files does not exist, please check it"
  echo "Get docker-ce binary from: https://download.docker.com/linux/static/stable/x86_64/"
  echo "eg: wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.0.tgz"
  exit 1
fi

echo "##unzip : tar xvpf ${FILETARGZ}"
tar xvpf ${FILETARGZ}
echo

echo "##binary : ${DOCKERBIN} copy to ${DOCKERDIR}"
cp -p ${DOCKERBIN}/* ${DOCKERDIR} >/dev/null 2>&1
which ${DOCKERBIN}

echo "##systemd service: ${SERVICEFILE}"
echo "##docker.service: create docker systemd file"
cat >${SYSTEMDDIR}/${SERVICEFILE} <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \\
                -H tcp://0.0.0.0:4243 \\
                -H unix:///var/run/docker.sock \\
                --selinux-enabled=false \\
                --log-opt max-size=1g
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=on-failure
[Install]
WantedBy=multi-user.target
EOF

echo ""

systemctl daemon-reload
echo "##Service status: ${SERVICENAME}"
systemctl status ${SERVICENAME}
echo "##Service restart: ${SERVICENAME}"
systemctl restart ${SERVICENAME}
echo "##Service status: ${SERVICENAME}"
systemctl status ${SERVICENAME}

echo "##Service enabled: ${SERVICENAME}"
systemctl enable ${SERVICENAME}

echo "## docker version"
docker version

install-docker-compose.sh

#/bin/bash
DOCKERDIR=/usr/bin
DOCKERBIN=docker-compose
JSONPROXY=daemon.json
JSONDIR=/etc/docker

if [ $# -lt 1 ]
then
  echo "not docker-compose"
  exit 1
fi
FILETARGZ="$1"

echo "##unzip : tar xvpf ${FILETARGZ}"
tar -xvpf ${FILETARGZ}
echo

echo "##binary : ${DOCKERBIN} copy to ${DOCKERDIR}"
cp -p ${DOCKERBIN} ${DOCKERDIR} >/dev/null 2>&1
which ${DOCKERBIN}

echo "docker_json proxy"
cp ${JSONPROXY} ${JSONDIR} >/dev/null 2>&1
echo

echo "docker-compose install successful!!"

daemon.json

{
 "registry-mirrors": ["https://registry.docker-cn.com"]
}

前两个sh授权

chmod +x *.sh

先执行install-docker再执行install-docker-compose,至于daemon.json是使用国内源

./install-docker.sh docker-18.09.0.tgz

./install-docker-compose.sh docker-compose.tar.gz

启动

 

以上是关于离线安装docker-compose的主要内容,如果未能解决你的问题,请参考以下文章

Linux离线安装docker&docker-compose

docker-compose安装

shell离线安装docker

Linux离线安装docker

centos离线安装Harbor

centos中离线安装docker 和docker compose