Docker installs Redis and turns on persistence

Source: Internet
Author: User
Tags gpg mkdir redis docker hub docker run redis server
Docker Installation Redis method One, build through Dockerfile

Create Dockerfile

First, create a directory Redis, which is used to store the related things behind.

runoob@runoob:~$ mkdir-p ~/redis ~/redis/data

The data directory will be mapped to the/data directory configured by the Redis container as the storage directory for Redis data persistence

Go to the created Redis directory and create the Dockerfile

From Debian:jessie # Add we user and group first to make sure their IDs get assigned consistently, regardless of whateve  R dependencies get added run Groupadd-r redis && useradd-r-G redis redis RUN apt-get update && Apt-get Install-y--no-install-recommends \ ca-certificates \ wget \ && RM-RF/  var/lib/apt/lists/* # Grab Gosu for easy step-down from root ENV gosu_version 1.7 RUN set-x \ && wget-o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU _version/gosu-$ (dpkg-- print-architecture) "\ && wget-o/usr/local/bin/gosu.asc" Https://github.com/tianon/gosu/releases/downloa d/$GOSU _version/gosu-$ (dpkg--print-architecture). ASC "\ && Export gnupghome=" $ (mktemp-d) "\ &amp ;& gpg--keyserver ha.pool.sks-keyservers.net--recv-keys b42f6819007f00f88e364fd4036a9c25bf357dd4 \ &&amp ; GPG--batch--VERIFY/USR/LOCAL/BIN/GOSU.ASC/usr/local/bin/gosu \ && rm-r "$GNUPGHOME"/USR/LOCAL/BIN/GOSU.ASC \ && chmod +x/usr/loc Al/bin/gosu \ && Gosu Nobody true env redis_version 3.2.0 env Redis_download_url Http://download.redis.io /releases/redis-3.2.0.tar.gz ENV redis_download_sha1 0c1820931094369c8cc19fc1be62f598bc5961ca # for Redis-sentinel See:http://redis.io/topics/sentinel RUN builddeps= ' gcc libc6-dev make ' \ && set-x \ && A Pt-get update && apt-get install-y $buildDeps--no-install-recommends \ && rm-rf/var/lib/apt/li sts/* \ && wget-o redis.tar.gz "$REDIS _download_url" \ && echo "$REDIS _download_sha1 *red Is.tar.gz "| Sha1sum-c-\ && mkdir-p/usr/src/redis \ && tar-xzf redis.tar.gz-c/usr/src/redis--s Trip-components=1 \ && rm redis.tar.gz \ && make-c/usr/src/redis \ && ma Ke-c/usr/src/reDis install \ && rm-r/usr/src/redis \ && apt-get purge-y--auto-remove $buildDeps RUN Mkdir/data && chown redis:redis/data volume/data workdir/data COPY docker-entrypoint.sh/usr/local/bin/entry Point ["docker-entrypoint.sh"] EXPOSE 6379 CMD ["Redis-server"]

Create a mirror from dockerfile and replace it with your own name

runoob@runoob:~/redis$ Docker build  -t redis:3.2.

Once created, we can find the image we just created in the local image list

runoob@runoob:~/redis$ Docker images Redis 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               3.2                 43c923d57784        2 weeks ago         193.9 MB
method Two, Docker pull redis:3.2

Find a Redis image on a docker hub

runoob@runoob:~/redis$ Docker search Redis NAME DESCRIPTION STARS official Autom   ATED Redis is an open source ... 2321 [OK] sameersbn/redis [OK] torusware/speedus-red   is always updated official ...             [OK] Bitnami/redis Bitnami redis Docker Image [OK] Anapsix/redis   11MB Redis Server Image ... 6 [OK] webhippie/redis Docker images for Redis 4 [OK] Clue/redis-ben   Chmark A minimal docker image t ... 3 [OK] williamyeh/redis Redis image for Docker 3 [OK] unblibraries/r   Edis leverages Phusion/baseim ...             2 [OK] Greytip/redis redis 3.0.3 1 [OK] Servivum/redis               Redis Docker Image 1     [OK] ... 

Here we pull the official image, labeled 3.2

runoob@runoob:~/redis$ Docker Pull  redis:3.2

After waiting for the download to complete, we can find the image of repository as Redis, labeled 3.2 In the local mirror list. using Redis mirroring Running the container

runoob@runoob:~/redis$ Docker run-p 6379:6379-v $PWD/data:/data-  d redis:3.2 redis-server--appendonly Yes
43f7a65ec7f8bd64eb1c5d82bc4fb60e5eb31915979c4e7821759aac3b62f330
runoob@runoob:~/redis$
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.