# 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有关。
发布于 2017-10-06 11:29:38
将下面的行添加到您的redis配置中:daemonize yes或使用redis-server --daemonize yes启动它,以实现Redis服务的去功能化。
或者,您可以从systemd或upstart启动Redis。
更新:ENTRYPOINT redis-server --daemonize yes && bash被证明是原海报的工作解决方案。
发布于 2023-03-10 21:33:17
这个问题老得令人痛苦,但我的搜索找到了,所以我会给出答案。
您误解了图像中ENTRYPOINT和CMD之间的关系。
如果您愿意的话,ENTRYPOINT是命令解释器。执行指定命令的是程序。当基于此映像的容器启动时,它将运行<ENTRYPOINT> <CMD>。因此,您是说您想要运行redis-server bash,这不太可能实现您的目标。
虽然您可以自由地将您的ENTRYPOINT设置为redis服务器,但如果不设置它,则会更正常。更自然的是,您可以设置CMD redis-server并将映像作为守护进程运行,然后根据需要执行它:
docker run --rm -d -p 6379:6379 --name redis my-image
docker exec -it redis bashhttps://serverfault.com/questions/877212
复制相似问题