Use Docker to install Redis images under Ubuntu and share with Redis containers

Source: Internet
Author: User
Tags redis version docker run install redis

Use Docker to install Redis images under Ubuntu and share with Redis containers

1. Install the UBUNTU2. Sign in to Ubuntu with Putty

Welcome to Ubuntu 14.04.1 LTS (gnu/linux 3.13.0-40-generic x86_64)

* documentation:https://help.ubuntu.com/

System information as of Wed Dec 06:41:16 UTC 2014

System load:0.01 processes:228
Usage of/: 6.0% of 28.80GB Users logged in:0
Memory usage:11% IP address for eth0:10.205.178.22
Swap usage:0% IP address for docker0:172.17.42.1

Graph this data and manage the system at:
https://landscape.canonical.com/

Get Cloud support with Ubuntu Advantage cloud Guest:
Http://www.ubuntu.com/business/services/cloud

3. Pull Redis Image

[email protected]: ~# sudo docker pull redis:latest
Redis:latest:The image you pulling have been verified
Eee46bd361c1:pull Complete
Ff8650f588b2:pull Complete
130985f77ca0:pull Complete
4d81fff38a25:pull Complete
E6d98faa32e2:pull Complete
95d3849978c3:pull Complete
263f96794544:pull Complete
1ed9b7611cf5:pull Complete
451742990a7f:pull Complete
511136ea3c5a:already exists
F10807909bc5:already exists
F6fab3b798be:already exists
1e6ac0ffed3b:already exists
62ff5003ac9a:already exists
E49d349e8a75:already exists
61213f5a1710:already exists
9feca322d1c7:already exists
1aa8ce669b93:already exists
status:downloaded newer image for Redis:latest
[email protected]: ~# sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
Redis latest 451742990a7f One days ago 111.2 MB

4. Start the Redis container

[email protected]: ~# sudo docker run-t-i Redis:latest
[1] Dec 02:56:57.870 # warning:no config file specified, using the default Config. In order to specify a config file use redis-server/path/to/redis.conf
_._
_.-' __ '-._
_.-``    `.  `_. "-._ Redis 2.8.19 (00000000/0)
.-`` .-```. ' \ \ _.,_ '-._
(',.-' | ',) Running in Stand alone mode
| '-._ '-...-' __...-. '-._| '     ' _.-' | port:6379
|     '-._ '. _/_.-' | Pid:1
'-._ '-._ '-./_.-' _.-'
| '-._ '-._ '-.__.-' _.-' _.-' |
|           '-._ '-._ _.-' _.-' | Http://redis.io
'-._ '-._ '-.__.-' _.-' _.-'
| '-._ '-._ '-.__.-' _.-' _.-' |
| '-._ '-._ _.-' _.-' |
'-._ '-._ '-.__.-' _.-' _.-'
'-._ '-.__.-' _.-'
'-._ _.-'
'-.__.-'

[1] Dec 02:56:57.890 # Server started, Redis version 2.8.19
[1] Dec 02:56:57.890 # WARNING Overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcom Mit_memory=1 ' for the take effect.
[1] Dec 02:56:57.891 # WARNING You has Transparent Huge Pages (THP) support enabled in your kernel. This would create latency and memory usage issues with Redis. To fix this issue run the command ' echo never >/sys/kernel/mm/transparent_hugepage/enabled ' as root, and add it to you R/etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
[1] Dec 02:56:57.891 # warning:the TCP Backlog setting of 511 cannot be enforced because/proc/sys/net/core/somaxconn is set to the lower value of 128.
[1] Dec 02:56:57.891 * The server is now ready for accept connections on port 6379

The 5.Redis container is up, so what happens next?

Method: Turn off the putty and come in again putty

6. How do I get into the container?

Install Nsenter First:

cd/tmp; Curl Http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/utils/util-linux/v2.25/util-linux-2.25.tar.gz | tar-zxf-; CD util-linux-2.25;
sudo apt-get install build-essential
sudo apt-get make
./configure--without-ncurses
Make Nsenter && sudo cp nsenter/usr/local/bin

Method One:

pid=$ (Docker inspect--format "{{. State.pid}} "<container>)

Nsenter--target $PID--mount--uts--ipc--net--pid

Method Two:

Installation script (script reference: Https://github.com/jpetazzo/nsenter/blob/master/docker-enter)

wget-p ~ Https://github.com/yeasy/docker_practice/raw/master/_local/.bashrc_docker;

echo "[-F ~/.bashrc_docker] &&. ~/.bashrc_docker ">> ~/.BASHRC; SOURCE ~/.BASHRC

Finally, call Docker-enter to enter the container:

[email protected]:/tmp# docker-enter b430d6f4ff00 ls
Dirname:invalid option--' s '
Try ' dirname--help ' for more information.
Bin boot data Dev entrypoint.sh etc home lib Lib64 media mnt opt proc root run sbin selinux SRV sys tmp usr var
[email protected]: ~#

Note: There are errors here, because the script is used to $ (dirname ""), you can directly echo " $ "I'm showing-su here.

7. Test Redis commands

After entering the container can use REDIS-CLI ping test can connect on the machine just started redis-server not, return pong the connection is successful.

Press REDIS-CLI directly into the Redis command test can be used without:


[email protected]: ~# redis-cli Ping
PONG
[email protected]: ~# redis-cli
127.0.0.1:6379> Set MyName jumping
Ok
127.0.0.1:6379> Get MyName
"Jumping"
127.0.0.1:6379>

8. This will simply start the Redis, to use the port to be mapped to the host machine, and then through the client to invoke the Redis:http://redis.io/clients

Use Docker to install Redis images under Ubuntu and share with Redis containers

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.