# 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
这里是我的Dockerfile的最后一部分。 我想运行以下命令:
docker run -it test_image
我想这个图像启动redis服务器,并离开我使用bash。
然而,它使我与redis服务器,虽然:
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
这与进入点和CMD有关。
daemonize yes添加到您的redisconfiguration中: daemonize yes或使用redis-server --daemonize yes启动它redis-server --daemonize yes以守护Redis服务。
或者,你可以从systemd或新贵开始Redis。
更新: ENTRYPOINT redis-server --daemonize yes && bash被certificate是原始海报的工作解决scheme。