当我运行docker-compose build&& docker-compose up redis,在docker-compose.yaml中指定的环境和Dockerfile中的RUN env,我设置的环境变量不会被打印.
为什么这不起作用?
我正在使用docker-compose版本1.4.2.
以下是相关文件:
docker-compose.yaml与环境作为KEY =值对的列表:
redis:
build: ../storage/redis
ports:
- "6379:6379"
environment:
- FOO='bar'
docker-compose.yaml,环境为字典:
redis:
build: ../storage/redis
ports:
- "6379:6379"
environment:
- FOO: 'bar'
Dockerfile:
FROM redis:2.6
MAINTAINER me@email.com
RUN mkdir -p /var/redis && chown -R redis:redis /var/redis
RUN echo '-------------- env ---------------'
RUN env
COPY redis.conf /usr/local/etc/redis/redis.conf
EXPOSE 6379
ENTRYPOINT ["redis-server","/usr/local/etc/redis/redis.conf"]
最佳答案