Home  >  Q&A  >  body text

docker 中怎么修改应用的配置?

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

黄舟黄舟2710 days ago788

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-22 08:58:15

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-22 08:58:15

    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

    reply
    0
  • Cancelreply