docker-compose

Install Docker Compose

1. Official Installation Documentation

#sudo curl -L "https://github.com/docker/compose/releases/download/1.29.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose 
 
docker-compose -v
# docker-compose version 1.24.0, build 0aa59064

  

curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o 

 

2. use pip to install

pip3 install docker-compose==

pip3 install docker-compose==1.28.6

#docker-compose -v
docker-compose version 1.28.6, build unknown

 

Use docker-compose

[0 root@vps /apps/docker_compose] #ss -ntl
State       Recv-Q Send-Q                        Local Address:Port                                       Peer Address:Port
LISTEN      0      128                                       *:22                                                    *:*
LISTEN      0      128                                    [::]:22                                                 [::]:*
[0 root@vps /apps/docker_compose] #cat docker-compose.yml
service-nginx-web:
  image: nginx:latest
  container_name: nginx-web
  restart: always
  volumes:
  - /data/nginx:/usr/share/nginx/html/
  expose:
  - 80
  - 443
  ports:
  - "80:80"
  - "443:443"
   
service-tomcat-app:
  image: tomcat:latest
  container_name: tomcat-app
  expose:
  - 8080
  ports:
  - "8088:8080"
[0 root@vps /apps/docker_compose] #docker-compose up -d
Pulling service-nginx-web (nginx:latest)...
latest: Pulling from library/nginx
a076a628af6f: Already exists
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Status: Downloaded newer image for nginx:latest
Creating nginx-web  ... done
Creating tomcat-app ... done
[0 root@vps /apps/docker_compose] #ss -ntl
State       Recv-Q Send-Q                        Local Address:Port                                       Peer Address:Port
LISTEN      0      128                                       *:8088                                                  *:*
LISTEN      0      128                                       *:443                                                   *:*
LISTEN      0      128                                       *:80                                                    *:*
LISTEN      0      128                                       *:22                                                    *:*
LISTEN      0      128                                    [::]:22                                                 [::]:*

[0 root@vps /apps/docker_compose] # docker-compose up -d --scale service-tomcat-app=2

[0 root@vps /apps/docker_compose] #docker-compose down
Stopping tomcat-app ... done
Stopping nginx-web ... done
Removing tomcat-app ... done
Removing nginx-web ... done
[0 root@vps /apps/docker_compose] #ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 128 [::]:22 [::]:*

  

 

  

 

posted @ 2021-05-17 06:57  AlexG  阅读(90)  评论(0编辑  收藏  举报