Docker learning (seven) combat - build REDIS Mirror

Docker learning (seven) combat - build REDIS Mirror

Enter a description of the picture here


Foreword

Official website has provided a base image Redis, try to use the official website provides the base image in a production environment, this article is mainly related to the integrated use of what Dockerfile command, let us understand some of the more in-depth

Real

Preparatory

Redis ready source package
configuration file

cd /usr/local/docker
mkdir docker-redis
cd docker-redis

We used to upload the source file to the current directory

Enter a description of the picture here

Write Dockerfile

vim Dockerfile increasing the following

FROM centos:centos7
RUN ["yum" , "install" , "-y" ,"gcc","gcc-c++","net-tools","make"]
WORKDIR /usr/local
ADD redis-4.0.14.tar.gz .
WORKDIR /usr/local/redis-4.0.14/src
RUN make && make install
WORKDIR /usr/local/redis-4.0.14
ADD redis-7000.conf .
EXPOSE 7000
CMD ["redis-server","redis-7000.conf"]

Enter a description of the picture here

Dockerfile interpretation

  1. Set the reference mirror centos
  2. Increase RUN command, when you run the command building yum install -y gcc gcc-c++ net-tools make
  • Installation gcc gcc-c ++ redis two components of the source code is compiled
  • net-tools Network tool installation package
  • Prerequisites make Setup
  1. Change directory to the container /usr/local
  2. Unpack redis-4.0.14.tar.gzthe container directory/usr/local
  3. Decompressed into the source code directory End
  4. Use gcc to compile the source code directory and install
  5. Switching to the working directory/usr/local.redis-4.0.14
  6. To redis-7000.confthe current working directory
  7. Exposing the interior of the container 7000port of the host
  8. Run the command redis-server redis-7000.confto start Redis

Packaged mirror

docker build -t albk.tech/docker-redis .

Enter a description of the picture here

View Mirror

docker images

Enter a description of the picture here

Background image

docker run -p 7000:7000 albk.tech/docker-redis

Enter a description of the picture here

View 7000 port is available

netstat -tulnp

Enter a description of the picture here

Redis into the container

docker ps 
docker exec -it f80c151f5d2f  /bin/bash

Enter a description of the picture here

redis-7000.conf has been hit by our script in the installation directory REDIS

to sum up

Here we have a good package redis own image, and in the actual work is not necessary to do so, the official had provided good correlation of the image, the paper just in front of Dockerfile command and docker command of integrated application

appendix

The actual environment to start redis

docker pull redis
docker run -d redis
These two lines of command would be able to create a redis container, if required for version, you can specify the corresponding version of the tag can

Written in the last

Related Articles will be starting public number, you can focus on the public number albk , you can get a lot of attention after learning video

Hope you love technology together to exchange and obtain the latest information and learning resources can focus on public number albk, personal blog !

Guess you like

Origin www.cnblogs.com/albk/p/12219945.html