当前位置:   article > 正文

安装docker-compose(国内高速镜像)配置文件及简单使用_docker compose 国内镜像安装

docker compose 国内镜像安装

安装docker-compose(国内高速镜像)
换成国内镜像(daocloud.io)来下载

docker-compose

1.国内源安装:

下载

curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  • 1
[root@localhost _data]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0     37      0  0:00:11  0:00:11 --:--:--   110
100 12.1M  100 12.1M    0     0   726k      0  0:00:17  0:00:17 --:--:-- 2740k

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

授权

chmod +x /usr/local/bin/docker-compose
  • 1
[root@localhost _data]# chmod +x /usr/local/bin/docker-compose
[root@localhost _data]# ls /usr/local/bin/docker-compose
/usr/local/bin/docker-compose
[root@localhost _data]# 
  • 1
  • 2
  • 3
  • 4

测试

docker-compose -v
  • 1
[root@localhost _data]# docker-compose -v
docker-compose version 1.29.2, build 5becea4c
[root@localhost _data]# 
  • 1
  • 2
  • 3

docker-compose.yml

version: "3.8"
services:
  nginx: 
    container_name: nginx1
    image: "nginx"
    ports:
      - "81:80"
    volumes:
      - nginx_v:/usr/share/nginx
    networks: 
      - host  
    

  redis:
    container_name: redis1
    image: "redis"
    ports:
      - "6379:6379" 
    networks: 
      - host 

  mysql:
    image: "mysql:5.7.32" 
    container_name: mysql1
    ports:
      - "3306:3306"
    volumes:
      - mysqldata:/var/lib/mysql
      - mysqlconf:/etc/mysql  
    networks: 
      - host  
    environment:
      - MYSQL_ROOT_PASSWORD=root      

volumes:
  nginx_v: {}
  mysqldata: {}
  mysqlconf: {}

networks:
  host:


volumes:
  nginx_v: {}

networks:
  host:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

启动(后台启动 docker-compose up -d)

docker-compose up
  • 1
[root@localhost dkc01]# docker-compose up
Starting nginx1 ... done
Starting redis1 ... done
Attaching to nginx1, redis1
nginx1   | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx1   | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx1   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx1   | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
nginx1   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx1   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx1   | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: using the "epoll" event method
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: nginx/1.21.1
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: built by gcc 8.3.0 (Debian 8.3.0-6) 
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: OS: Linux 3.10.0-1062.el7.x86_64
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: start worker processes
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: start worker process 25
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: start worker process 26
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: start worker process 27
nginx1   | 2021/08/22 09:29:43 [notice] 1#1: start worker process 28
redis1   | 1:C 22 Aug 2021 09:29:43.688 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis1   | 1:C 22 Aug 2021 09:29:43.689 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis1   | 1:C 22 Aug 2021 09:29:43.689 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis1   | 1:M 22 Aug 2021 09:29:43.689 * monotonic clock: POSIX clock_gettime
redis1   | 1:M 22 Aug 2021 09:29:43.689 * Running mode=standalone, port=6379.
redis1   | 1:M 22 Aug 2021 09:29:43.690 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis1   | 1:M 22 Aug 2021 09:29:43.690 # Server initialized
redis1   | 1:M 22 Aug 2021 09:29:43.690 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis1   | 1:M 22 Aug 2021 09:29:43.690 * Loading RDB produced by version 6.2.5
redis1   | 1:M 22 Aug 2021 09:29:43.690 * RDB age 319 seconds
redis1   | 1:M 22 Aug 2021 09:29:43.690 * RDB memory usage when created 0.77 Mb
redis1   | 1:M 22 Aug 2021 09:29:43.690 * DB loaded from disk: 0.000 seconds
redis1   | 1:M 22 Aug 2021 09:29:43.690 * Ready to accept connections

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

停止(不是后台启动直接ctrl + c)

docker-compose stop
  • 1
[root@localhost dkc01]# docker-compose stop
Stopping nginx1 ... done
Stopping redis1 ... done
[root@localhost dkc01]# 

  • 1
  • 2
  • 3
  • 4
  • 5

找到卷映射信息

docker volume ls
  • 1
[root@localhost dkc01]# docker volume ls
DRIVER    VOLUME NAME
local     35b2b4543711ce9f3d2468108043db2b1af3cc78e29f50ff6677a14658985a3d
local     75ee95ab59ab18666a78eb13cc52744ae3d07b9fd0580c5290ff65a6191b6a2c
local     091e8b5899f9535840b3e17fb97167017a7f681a0a13f2236f8cb00b1439e4e7
local     9944b1c699ac07d93fab3a54aaaba249981ac708348e2f6bcb435522f89e34da
local     dkc01_nginx-v
local     dkc01_nginx_v
local     e9bef9b37bb1c2d059d8b4da65c9ce0eb3b484a2575ccf0ae02d2be713654e96
local     fd7060b7cb119e6d2d21657498423b6f53e5f7933d3555bca62dec11cfd59ce8

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

查看卷具体信息

Mountpoint": "/var/lib/docker/volumes/dkc01_nginx_v/_data 就是实际的映射目录

[root@localhost dkc01]# docker volume inspect dkc01_nginx_v
[
    {
        "CreatedAt": "2021-08-21T12:32:42-04:00",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "dkc01",
            "com.docker.compose.version": "1.29.2",
            "com.docker.compose.volume": "nginx_v"
        },
        "Mountpoint": "/var/lib/docker/volumes/dkc01_nginx_v/_data",
        "Name": "dkc01_nginx_v",
        "Options": null,
        "Scope": "local"
    }
]

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
# 容器内nginx对应的映射目录
[root@localhost dkc01]# cd /var/lib/docker/volumes/dkc01_nginx_v/_data
[root@localhost _data]# ls
html
[root@localhost _data]#
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/388802
推荐阅读
相关标签
  

闽ICP备14008679号