Docker & docker-compose安装

Posted May 25, 20202 min read

docker

  1. The download speed of docker domestic access is too slow, borrow the third-party DaoCloud docker installation source

    curl -sSL https://get.daocloud.io/docker | sh

  2. After the installation is complete, use docker info to view the docker status, but you need to use sudo permissions, because the docker command belongs to the docker user group, in order to avoid the need to bring sudo every time you enter the command, you can add the current user to the docker group

    sudo gpasswd -a $(whoami) docker

  3. Configure image acceleration

    sudo mkdir -p/etc/docker
    sudo tee /etc/docker/daemon.json <<-'EOF'
    {
    "registry-mirrors":["https://**.mirror.aliyuncs.com"]
    }
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker

docker-compose

  1. docker-compose is stored on github, the installation speed is not ideal, or borrow the docker-compose installation source provided by DaoCloud

    curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s-uname -m`>/usr/local/bin/docker- compose
    chmod + x/usr/local/bin/docker-compose

  2. Commonly used docker-compose

.env:

DCOMPOSE_DIR =/data/dcompose

MYSQL_ROOT_PASSWORD = 123456

docker-compose.yml:(automatically load .env in the same directory)

version:"3"
services:
  mysql:
    image:mysql:5.7
    container_name:mysql
    restart:on-failure:3
    environment:
      # Environment variables
      -MYSQL_ROOT_PASSWORD = ${MYSQL_ROOT_PASSWORD}
    volumes:
      -"${DCOMPOSE_DIR}/mysql/data:/var/lib/mysql"
      -"${DCOMPOSE_DIR} /mysql/conf.d:/etc/mysql/conf.d"
    ports:
      -3306:3306

  tengine:
    image:axizdkr/tengine:2.3.2
    container_name:tengine
    restart:on-failure:3
    environment:
      -TZ = Asia/Shanghai
      -LANG = zh_CN.UTF-8
    ports:
      -"80:80"
      -"443:443"
    volumes:
      -${DCOMPOSE_DIR} /tengine/conf.d /:/etc/nginx/conf.d /
      -${DCOMPOSE_DIR}/tengine/log /:/var/log/nginx /