docker——用docker-compose安装redis

安装 docker-compose

yum list docker-compose

yum install docker-compose.noarch

docker-compose -v

编辑  docker-compose.yml 文件

  redis:
    image: docker.io/redis:3.2.10
    container_name: myredis
    restart: always
    command: ["redis-server" ,"--appendonly" ,"yes"]
    ports:
     - "30001:6379"
    volumes:
     - /root/data/soft/docker/compose-redis/redisdata:/data

启动

docker-compose up -d

停止

docker-compose down

注意此命令相当于 docker stop xxx 与 docker rm xxx 的组合

测试redis是否启动

redis-cli -h 172.31.140.161 -p 30001 keys "*"

 

 

posted @ 2021-05-06 14:27  会飞的斧头  阅读(3432)  评论(0编辑  收藏  举报