Skip to content

Instantly share code, notes, and snippets.

@mingder78
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingder78/31a13eb38f3f4483ca67 to your computer and use it in GitHub Desktop.
Save mingder78/31a13eb38f3f4483ca67 to your computer and use it in GitHub Desktop.
run redis on docker
$ docker run dockerfile/redis
Unable to find image 'dockerfile:redis' locally
Pulling repository dockerfile/redis
0a422c0cdf16: Download complete
511136ea3c5a: Download complete
5e66087f3ffe: Download complete
4d26dd3ebc1c: Download complete
d4010efcfd86: Download complete
99ec81b80c55: Download complete
b261bc65cd23: Download complete
42404685406e: Download complete
6cc69450fe19: Download complete
efc4fbcd007f: Download complete
2baeb2edbf92: Download complete
ecd5c1cc18ac: Download complete
1f089cc15e82: Download complete
c2b10e69958d: Download complete
3325d896eead: Download complete
7dc90913d288: Download complete
44a157fa59c3: Download complete
[1] 15 Jul 16:07:27.555 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 15 Jul 16:07:27.555 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 15 Jul 16:07:27.555 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6cba4a4bcad4 dockerfile/redis:latest redis-server /etc/re 8 hours ago Up 8 hours 6379/tcp elegant_tesla
// to find ip address of redis server which is running...
$ CID=$(docker run -d -p 4321 dockerfile/redis nc -lk 4321); [9:06:18]
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID} \
172.17.0.3
// I still can not connect to redis server using this ip address
@mingder78
Copy link
Author

$ docker inspect ${CID} [9:13:05]
[{
"Args": [
"-lk",
"4321"
],
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"nc",
"-lk",
"4321"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": null,
"Env": [
"HOME=/root",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": {
"4321/tcp": {},
"6379/tcp": {}
},
"Hostname": "c0091c52a641",
"Image": "dockerfile/redis",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/data": {}
},
"WorkingDir": "/data"
},
"Created": "2014-07-16T01:06:37.37015546Z",
"Driver": "aufs",
"ExecDriver": "native-0.2",
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"Dns": null,
"DnsSearch": null,
"Links": null,
"LxcConf": [],
"NetworkMode": "bridge",
"PortBindings": {
"4321/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "49153"
}
],
"6379/tcp": null
},
"Privileged": false,
"PublishAllPorts": false,
"VolumesFrom": null
},
"HostnamePath": "/var/lib/docker/containers/c0091c52a6413783cc44261b184322383f036269b712e03d8107a3b16189f997/hostname",
"HostsPath": "/var/lib/docker/containers/c0091c52a6413783cc44261b184322383f036269b712e03d8107a3b16189f997/hosts",
"Id": "c0091c52a6413783cc44261b184322383f036269b712e03d8107a3b16189f997",
"Image": "0a422c0cdf16360e5b297fa85ce4942023132fc24bd5f0f471c9c2055ed80a5a",
"MountLabel": "",
"Name": "/focused_thompson",
"NetworkSettings": {
"Bridge": "docker0",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"PortMapping": null,
"Ports": {
"4321/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "49153"
}
],
"6379/tcp": null
}
},
"Path": "nc",
"ProcessLabel": "",
"ResolvConfPath": "/etc/resolv.conf",
"State": {
"ExitCode": 0,
"FinishedAt": "0001-01-01T00:00:00Z",
"Paused": false,
"Pid": 1034,
"Running": true,
"StartedAt": "2014-07-16T01:06:37.63763289Z"
},
"Volumes": {
"/data": "/var/lib/docker/vfs/dir/62c5ce9dccfc2b61ac1c2fc52dcb43e31522e7818849534a2b12f47a52e17ba2"
},
"VolumesRW": {
"/data": true
}
}
]

@mingder78
Copy link
Author

or run

$ docker run -i -t redis redis-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment