노션링크에 들어가서 보셔도 됩니다.
읽기좋으시라고 디시 글에도 png로 떠왔습니다.
ctrl + shift + L 하시면 다크모드로 보실 수 있어요 .. !
https://descriptive-cardinal-be4.notion.site/dockerfile-compose-d857e906a5074b7db34e6a97cd3ba58a
노션링크에 들어가서 보셔도 됩니다.
읽기좋으시라고 디시 글에도 png로 떠왔습니다.
ctrl + shift + L 하시면 다크모드로 보실 수 있어요 .. !
https://descriptive-cardinal-be4.notion.site/dockerfile-compose-d857e906a5074b7db34e6a97cd3ba58a
긴... 글?
정성추
docker build도 프로젝트 루트 폴더에서 -f 지정하면 안될거같은데
중간에 RUN pwd 추가해서 뭐라 나오는지 비교좀요
니가 쓰는 docker나 docker-compose는 그냥 cli고 실제 build 하는건 docker daemon이 하게 됨.
https://docs.docker.com/engine/reference/commandline/build/
에서 "all the files in the local directory get tard and sent to the Docker daemon." 라고 쓰여진 부분임. 아마 docker로는 requirements.txt가 있는 경로에서 build 해서 requirements.txt도 같이 daemon으로 넘어갔을거고 docker-compose로 빌드할때는 그러지 못해서 나는 에러로 보임
따라서 docker-compose의 context를 . 에서 .. 으로 바꾸는것을 제안함
참고로 Dockerfile 내에서 부모 경로를 참조하는거 자체는 원래 안됨.
https://docs.docker.com/engine/reference/builder/#copy
의 "COPY obeys the following rules" 절 참고. 해당 구문을 그대로 복붙하니까 꺽쇠괄호때문에 댓글이 안올라감. 그런데 너가 docker에서 build가 됐던 이유는 buildkit 때문으로 보임. 너가 원래 잘되던 docker build ... 앞에 `DOCKER_BUILDKIT=0 docker build -f ...` 이런식으로 하면 에러가 날거임. docker-compose에서도 굳이 부모경로에 접근해서 작업하고 싶다면
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose ... 이런식으로 해줘야 함. context도 수정해줘야 하고.
https://docs.docker.com/compose/compose-file/compose-file-v3/
의 context 설명 보면 "When the value supplied is a relative path, it is interpreted as relative to the location of the Compose file." 라고 하니 아마 예상한대로 동작할거임
답변사무치게 감사드립니다. 먼저 context를 . 으로 했던이유는 같은 경로에 Dockerfile이 있어서 였던것인데 .. 으로 바꾸니 그에따른 오류가 또 났습니다. 그냥 docker , docker-compose 모두 프로젝트루트로 올리는 걸로 해결해야만 하는 걸까요? 오픈소스들 도커파일들보면 docker디렉토리에 넣어놓고 하는 경우도 많길래 그렇게 하려고 한건데 계속 성가시게 하는 질문드리는 거 같아 죄송합니다.
context문제