参考博客:
https://blog.csdn.net/F_TimeOk/article/details/87861901

docker 安装:

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager \
—add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

[root@docker-compose ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    repo id repo name status
    base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,097
    docker-ce-stable/x86_64 Docker CE Stable - x86_64 63
    epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,509
    extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 307
    updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,010
    repolist: 24,986
    [root@docker-compose ~]#

[root@docker-compose ~]# yum list docker-ce —showduplicates|sort -r

  • updates: mirrors.aliyun.com
    Loading mirror speeds from cached hostfile
    Loaded plugins: fastestmirror
  • extras: mirrors.aliyun.com
    docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
    docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
    docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
    docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
    docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
    docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
    docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
    docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
    docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
    docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
  • base: mirrors.aliyun.com
    Available Packages
    [root@docker-compose ~]#

yum install docker-ce-18.06.3.ce-3.el7 -y

加速:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://0[bb06s1q.mirror.aliyuncs.com](http://bb06s1q.mirror.aliyuncs.com/)”]
}
EOF

systemctl daemon-reload && systemctl start docker && systemctl enable docker.service

docker-compose 版本:
https://github.com/docker/compose/releases

1.25.1

  1. curl -L https://github.com/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  2. chmod +x /usr/local/bin/docker-compose

Compose file format compatibility matrix

Compose file format Docker Engine
1 1.9.0+
2.0 1.10.0+
2.1 1.12.0+
2.2, 3.0, 3.1, 3.2 1.13.0+
2.3, 3.3, 3.4, 3.5 17.06.0+
2.4 17.12.0+
3.6 18.02.0+
3.7 18.06.0+

安装方式 1:

wget https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m)
mv docker-compose-Linux-x86_64 docker-compose
mv docker-compose /usr/local/bin/
chmod +x /usr/local/bin/docker-compose

官网地址:https://docs.docker.com/compose/install/
运行此命令以下载Docker Compose的当前稳定版本

sudo curl -L ``"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o ``/usr/local/bin/docker-compose sudo curl -L ``"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o ``/usr/local/bin/docker-compose

换成国内的

sudo curl -L ``"https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o ``/usr/local/bin/docker-compose sudo curl -L ``"https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o ``/usr/local/bin/docker-compose

对二进制文件应用可执行权限:

chmod +x ``/usr/local/bin/docker-compose chmod +x ``/usr/local/bin/docker-compose

安装完成后,可测试 docker-compose —version

安装方式2:epel源 docker-compose.noarch 0:1.18.0-4.el7
yum install docker-compose -y

应用:
安装gitlab

[root@docker-compose ~]# docker pull twang2218/gitlab-ce-zh
Using default tag: latest
latest: Pulling from twang2218/gitlab-ce-zh
8ee29e426c26: Pull complete
6e83b260b73b: Pull complete
e26b65fd1143: Pull complete
40dca07f8222: Pull complete
b420ae9e10b3: Pull complete
a218309dd589: Pull complete
5c60fd7ba0ce: Pull complete
659c2144b5a3: Pull complete
8289bbac0d0e: Pull complete
31bbd150e8a7: Pull complete
9114e78243fa: Pull complete
e242e5cd1314: Pull complete
0a079dc3f92c: Pull complete
f0e195b09fd2: Pull complete
6e23346e2f58: Pull complete
91f00659be69: Pull complete
a1031bcc5b2c: Pull complete
e3074327c7b1: Pull complete
a917618dbe42: Pull complete
Digest: sha256:62686b74c6fca5ece8ed582d03a126c5988423dd8a19ce70e9a22357ffcaf1c8
Status: Downloaded newer image for twang2218/gitlab-ce-zh:latest
[root@docker-compose ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
twang2218/gitlab-ce-zh latest 18da462b5ff5 17 months ago 1.61GB
[root@docker-compose ~]#

[root@docker-compose local]# cat docker-compose.yml
version: ‘3’
services:
web:
image: ‘twang2218/gitlab-ce-zh’
restart: always
hostname: ‘IP地址’
environment:
TZ: ‘Asia/Shanghai’
GITLAB_OMNIBUS_CONFIG: |
external_url ‘http://IP地址:8080
gitlab_rails[‘gitlab_shell_ssh_port’] = 2222
unicorn[‘port’] = 8888
nginx[‘listen_port’] = 8080
ports:
- ‘8080:8080’
- ‘8443:443’
- ‘2222:22’
volumes:
- /usr/local/docker/gitlab/config:/etc/gitlab
- /usr/local/docker/gitlab/data:/var/opt/gitlab
- /usr/local/docker/gitlab/logs:/var/log/gitlab

[root@docker-compose local]# cat docker-compose.yml
version: ‘3’
services:
web:
image: ‘twang2218/gitlab-ce-zh’
restart: always
hostname: ‘192.168.31.82’
environment:
TZ: ‘Asia/Shanghai’
GITLAB_OMNIBUS_CONFIG: |
external_url ‘http://192.168.31.82:8080
gitlab_rails[‘gitlab_shell_ssh_port’] = 2222
unicorn[‘port’] = 8888
nginx[‘listen_port’] = 8080
ports:
- ‘8080:8080’
- ‘8443:443’
- ‘2222:22’
volumes:
- /usr/local/docker/gitlab/config:/etc/gitlab
- /usr/local/docker/gitlab/data:/var/opt/gitlab
- /usr/local/docker/gitlab/logs:/var/log/gitlab
[root@docker-compose local]#

[root@docker-compose local]# docker-compose up -d
Starting local_web_1 … done
[root@docker-compose local]#

[root@docker-compose local]# docker-compose ps
Name Command State Ports
—————————————————————————————————————————————————————————————
local_web_1 /assets/wrapper Up (healthy) 0.0.0.0:2222->22/tcp, 0.0.0.0:8443->443/tcp, 80/tcp, 0.0.0.0:8080->8080/tcp
[root@docker-compose local]#

web界面访问:

192.168.31.82:8080

image.png

安装habor :https://goharbor.io/