Docker learning (seven) combat - build REDIS Mirror
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
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"]
Dockerfile interpretation
- Set the reference mirror centos
- 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
- Change directory to the container
/usr/local
- Unpack
redis-4.0.14.tar.gz
the container directory/usr/local
- Decompressed into the source code directory End
- Use gcc to compile the source code directory and install
- Switching to the working directory
/usr/local.redis-4.0.14
- To
redis-7000.conf
the current working directory - Exposing the interior of the container
7000
port of the host - Run the command
redis-server redis-7000.conf
to start Redis
Packaged mirror
docker build -t albk.tech/docker-redis .
View Mirror
docker images
Background image
docker run -p 7000:7000 albk.tech/docker-redis
View 7000 port is available
netstat -tulnp
Redis into the container
docker ps
docker exec -it f80c151f5d2f /bin/bash
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 !