# Redis
# Download and extract Redis source files
RUN curl -o redis.tar.gz "http://download.redis.io/releases/redis-4.0.2.tar.gz" && \
mkdir redis_tmp/ && \
tar xzf redis.tar.gz -C redis_tmp && \
# Rename temporary directory
mv redis_tmp/* redis && \
# Install Redis
cd redis && \
make && \
make install && \
# Remove source files
cd .. && \
rm -rf redis && \
# Confirm installation
redis-server -v
# Cleanup
# Remove local repository package files
RUN apt-get -y clean
ENTRYPOINT redis-server
CMD bash
Here the last part of my Dockerfile. I'd like to run the following command:
docker run -it test_image
I'd like this image to startup redis-server and leave me using bash.
It leaves me with redis-server though:
kmorrison@Karl ~/dev/test_image (master) $ docker run -it test_image
9:C 06 Oct 10:09:23.266 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9:C 06 Oct 10:09:23.266 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=9, just started
9:C 06 Oct 10:09:23.266 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.2 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 9
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
9:M 06 Oct 10:09:23.268 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9:M 06 Oct 10:09:23.268 # Server initialized
9:M 06 Oct 10:09:23.268 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
9:M 06 Oct 10:09:23.268 * Ready to accept connections
It has something to do with ENTRYPOINT and CMD.
Add the following line to your redis configuration:
daemonize yes
or start it withredis-server --daemonize yes
to daemonize the Redis service.Alternatively you can start Redis from systemd or upstart.
Update:
ENTRYPOINT redis-server --daemonize yes && bash
proved to be the working solution for the original poster.