Docker redis
跳到导航
跳到搜索
自己dockerfile 4.014
cd /data/ && mkdir -p ~/redis ~/redis/data docker build --tag evan886/redis:4.0.14 -f Dockerfile .
usage
/data/redis docker build --tag evan886/redis:3.2 -f Dockerfile . 启动redis docker run -d -p 6379:6379 --name myredis registry.docker-cn.com/library/redis docker启动redis并设置密码 开启持久化 docker run -d --name myredis -p 6379:6379 redis --requirepass "mypassword" --appendonly yes docker run -p 6379:6379 -v $PWD/data:/data -d redis:3.2 redis-server --appendonly yes 创建宿主机 redis 容器的数据和配置文件目录 # 这里我们在 /home/docker 下创建 mkdir /home/docker/redis/{conf,data} -p cd /home/docker/redis * dockerfile cd /data/ mkdir -p ~/redis ~/redis/data cd redis vi Dockerfile [root@localhost data]# docker images redis REPOSITORY TAG IMAGE ID CREATED SIZE redis 3.2 87856cc39862 8 months ago 76MB 用法 指定目录 redis数据持久化的存储目录 加密码 指定自己的配置文件 最多就是这三个喽 docker build --tag evan886/redis:4.0.14 -f Dockerfile . docker run --name myredis3.2 -p 6379:6379 -v /data/redis/data:/data -d redis:3.2 redis-server --appendonly yes 3162d9507300 docker run -v /myredis/conf/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf un redis-server with persistent data directory and password. docker run -d -p 6379:6379 -v <data-dir>:/data --name redis dockerfile/redis redis-server /etc/redis/redis.conf --requirepass <password> Run redis-cli docker run -it --rm --link redis:redis dockerfile/redis bash -c 'redis-cli -h redis' #这个要改进一下下 [root@localhost data]# docker run -p 6379:6379 -v $PWD/data:/data -d redis:3.2 redis-server cli 暂时可以用 [root@localhost data]# docker exec -it f04dd54bea7b redis-cli 127.0.0.1:6379> info # Server redis_version:3.2.12 redis_git_sha1:00000000
https://github.com/docker-library/redis/blob/9519b0469cc8410808b1741c9372394a4b37b1c0/4.0/Dockerfile
Redis常用操作
trouble
+ echo *redis.tar.gz + sha256sum -c - sha256sum: 'standard input': no properly formatted SHA256 checksum lines found #定义这个变量多了一个1 哈哈 ENV REDIS_DOWNLOAD_SHA 0c1820931094369c8cc19fc1be62f598bc5961ca Step 13/15 : COPY docker-entrypoint.sh /usr/local/bin/ COPY failed: stat /var/lib/docker/tmp/docker-builder386922783/docker-entrypoint.sh: no such file or directory [root@localhost data]# ******************************************** pull 一个4.0下来 然后进去拿出来就行了 docker pull redis:4.0.14 [root@localhost tmp]# docker run -p 6379:6379 -v $PWD/data:/data -d redis:4.0.14 redis-server --appendonly yes de0fb9f8592e0636363d491e87fbe8feb126f49f118fea794e15cf65a31dc188 [root@localhost tmp]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES de0fb9f8592e redis:4.0.14 "docker-entrypoint.s…" 16 seconds ago Up 15 seconds 0.0.0.0:6379->6379/tcp romantic_leakey b008e3db67f0 mysql:5.7 "docker-entrypoint.s…" 3 days ago Up 8 hours 33060/tcp, 0.0.0.0:3307->3306/tcp root_db_1 [root@localhost tmp]# docker exec -it de0fb9f8592e /bin/bash cat /usr/local/bin/docker-entrypoint.sh docker run -p 6379:6379 -v $PWD/data:/data -d redis:3.2 redis-server --appendonly yes docker exec -it 148bb6a02e4a /bin/bash
see also
https://hub.docker.com/_/redis/