我有一个设置,其中气流在docker容器中运行,并且它的日志目录映射到主机中的目录。在运行时,它会创建一个文件系统链接/usr/local/airflow/logs/scheduler/latest
,该容器在容器内部具有有效目标,但在主机中没有。下次运行docker-compose build
时,它会在该链接上跳转并导致构建失败。
我已经尝试忽略.dockerignore中的日志目录,但这并未改变任何内容。
我的设置的相关部分如下:
工作目录
***/docker/
airflow/
logs/
scheduler/
...
2018-01-30/
latest -> /usr/local/airflow/logs/scheduler/2018-01-30
.dockerignore
Dockerfile
...
docker-compose.yml
...
搬运工-compose.yml
version: '2'
services:
...
airflow:
...
build:
dockerfile: airflow/Dockerfile
context: .
environment:
- LOAD_EX=n
- EXECUTOR=Local
volumes:
- ./airflow/logs:/usr/local/airflow/logs/
...
Dockerfile
FROM puckel/docker-airflow:1.8.1
USER root
...
RUN chown -R airflow: /usr/local/airflow
USER airflow
...
.dockerignore
./logs
...
错误我进入终端:
$ pwd
/***/docker
$ docker-compose build
Building airflow
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 71, in main
command()
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 124, in perform_command
handler(command, command_options)
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 254, in build
build_args=build_args)
File "/usr/local/lib/python2.7/dist-packages/compose/project.py", line 364, in build
service.build(no_cache, pull, force_rm, memory, build_args)
File "/usr/local/lib/python2.7/dist-packages/compose/service.py", line 967, in build
'memory': parse_bytes(memory) if memory else None
File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", line 150, in build
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
File "/usr/local/lib/python2.7/dist-packages/docker/utils/build.py", line 14, in tar
root=root, fileobj=fileobj, gzip=gzip
File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 103, in create_archive
'Can not access file in context: {}'.format(full_path)
IOError: Can not access file in context: /***/docker/airflow/logs/scheduler/latest
如果我在运行airflow/logs/
之前删除docker-compose build
的内容,一切正常,气流再次创建相同的链接,我必须继续删除它。
我喜欢docker-compose完全忽略airflow/logs
目录。理想情况下,在主机中,没有从容器内部创建的文件系统链接气流。
编辑以回应我的问题被标记为Mount host directory with a symbolic link inside in docker container的潜在副本
airflow/logs
目录; 答案 0 :(得分:2)
看起来你的.dockerignore文件被docker守护程序忽略了。尝试将./logs更改为./airflow/logs / **
here是.dockerignore docs
的链接答案 1 :(得分:2)
您的.dockerignore
可能无法生效,因为您为气流设置的构建上下文为.
,这与您的.dockerignore
文件所在的目录不同。 Docker compose正在相对于构建上下文的位置中查找您的.dockerignore
文件。
在docker-compose.yml
中,尝试将构建上下文设置为./airflow
,将dockerfile设置为Dockerfile
。
airflow:
...
build:
dockerfile: Dockerfile
context: ./airflow
这应该有助于Docker Compose在构建时找到您的.dockerignore
文件。