docker
是一个供开发和运维人员开发,测试,部署和运行应用的容器平台。这种用linux container部署应用的方式叫容器化。
http://mirrors.163.com/docker-ce/linux/static/stable/x86_64/
docker-compose
是一个用于运行和管理多个容器化应用的工具(一系列的容器)
https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
https://github.com/docker/compose/releases/ #有各种版本
docker和 docker-compose二者对比下:
1.docker是自动化构建镜像,并启动镜像。 docker compose是自动化编排容器。
2.docker是基于Dockerfile得到images,启动的时候是一个单独的container
3.docker-compose是基于docker-compose.yml,通常启动的时候是一个服务,这个服务通常由多个container共同组成,并且端口,配置等由docker-compose定义好。
4.两者都需要安装,但是要使用docker-compose,必须已经安装docker
docker应用实例:
# centos7
# 从阿里云直接下载docker-ce.repo文件
[root@centos7 ~]#wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@centos7 ~]#yum repolist
[root@centos7 ~]#yum list docker-ce* --showduplicates | sort -r
[root@centos7 ~]#yum -y install docker-ce-19.03.13-3.el7 docker-ce-cli-19.03.13-3.el7
# centos安装完后需要手动启动docker
[root@centos7 ~]#systemctl enable --now docker
#查看版本,验证安装成功
[root@centos7 ~]#docker --version
Docker version 19.03.13, build 4484c46d9d
以下docker-compose是重点
docker-compose应用实例(用docker-compose方式管理harbor):
docker ps 启动的容器,都是harbor相关的一系列容器
[root@fp-web-169 harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce658cd5d04e goharbor/nginx-photon:v1.8.0 "nginx -g 'daemon of…" 4 months ago Up 4 months (healthy) 0.0.0.0:80->80/tcp nginx
5be3c8cd5f4d goharbor/harbor-portal:v1.8.0 "nginx -g 'daemon of…" 4 months ago Up 4 months (healthy) 80/tcp harbor-portal
7c9bfd2d4693 goharbor/harbor-jobservice:v1.8.0 "/harbor/start.sh" 4 months ago Up 4 months harbor-jobservice
50133b195021 goharbor/harbor-core:v1.8.0 "/harbor/start.sh" 4 months ago Up 4 months (healthy) harbor-core
f8c82eb02dcb goharbor/harbor-db:v1.8.0 "/entrypoint.sh post…" 4 months ago Up 4 months (healthy) 5432/tcp harbor-db
748be8a5a061 goharbor/registry-photon:v2.7.1-patch-2819-v1.8.0 "/entrypoint.sh /etc…" 4 months ago Up 4 months (healthy) 5000/tcp registry
de2b1a33cd0c goharbor/redis-photon:v1.8.0 "docker-entrypoint.s…" 4 months ago Up 4 months 6379/tcp redis
039ca1596261 goharbor/harbor-pctl:v1.8.0 "/harbor/start.sh" 4 months ago Up 4 months (healthy) pctl
3d724b925790 goharbor/harbor-log:v1.8.0 "/bin/sh -c /usr/loc…" 4 months ago Up 4 months (healthy) 127.0.0.1:1514->10514/tcp harbor-log