docker 中怎么修改应用的配置?
黄舟
黄舟 2017-04-22 08:56:15
0
2
786

比如我下载了一个redis的镜像,我想在启动redis容器前修改redis的配置,去哪里修改呢?另外docker到底把redis安装到哪里去了?我在docker的命令行里面好像没法find到redis的安装目录啊

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
PHPzhong

If you want to modify the configuration,
there are several methods as follows:

1. Read the readme of the redis image provider and follow his method (usually by changing ENV)
2. Use the data volume method to mount the redis configuration file into it
3. Docker run starts an instance first , go in and modify it. After the modification is completed, docker commit to turn this container into a mirror.

The first one is generally recommended.

洪涛

I agree with the approach above.

  • The first thing I thought of when I saw this question was to go docker hub搜官方的redis镜像.然后看了redis的Dockerfile .
    The official method is (corresponding to 1 above)

Additionally, If you want to use your own redis.conf ...
You can create your own Dockerfile that adds a redis.conf from the context into /data/, like so

FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

or

$ docker run -v /myredis/conf/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf
  • This image will run by default when it starts. Just go in and overwrite the default startup command and add your own configuration. redis-server了。无法通过docker run -it redis修改。试图docker run -it redis /bin/bash

Hope it helps you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!