Reputation: 11641
Why docker compose takes too long to begin building an image? Docker waits ~10 minutes until it began. There is not node_modules or big files in my images.
When I add the verbose
flag I can the see log:
$docker-compose --verbose -f .docker/docker-compose.my.yml build
compose.config.config.find: Using configuration files: .\.docker/docker-compose.my.yml
docker.utils.config.find_config_file: Trying paths: ['C:\\Users\\user\\.docker\\config.json', 'C:\\Users\\user\\.dockercfg']
docker.utils.config.find_config_file: Found file at path: C:\Users\user\.docker\config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Auth data for 00000.dkr.ecr.us-east-2.amazonaws.com is absent. Client might be using a credentials store instead.
docker.auth.parse_auth: Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
docker.auth.load_config: Found 'credsStore' section
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/version HTTP/1.1" 200 560
compose.cli.command.get_client: docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
compose.cli.command.get_client: Docker base_url: http+docker://localnpipe
compose.cli.command.get_client: Docker version: Platform={'Name': 'Docker Engine - Community'}, Components=[{'Name': 'Engine', 'Version': '18.09.1', 'Details': {'ApiVersion': '1.39', 'Arch': 'amd64', 'BuildTime': '2019-01-09T19:41:49.000000000+00:00', 'Experimental': 'false', 'GitCommit': '4c52b90', 'GoVersion': 'go1.10.6', 'KernelVersion': '4.9.125-linuxkit', 'MinAPIVersion': '1.12', 'Os': 'linux'}}], Version=18.09.1, ApiVersion=1.39, MinAPIVersion=1.12, GitCommit=4c52b90, GoVersion=go1.10.6, Os=linux, Arch=amd64, KernelVersion=4.9.125-linuxkit, BuildTime=2019-01-09T19:41:49.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('docker_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/docker_default HTTP/1.1" 404 47
compose.service.build: Building app-www
compose.cli.verbose_proxy.proxy_callable: docker build <- (path='\\\\?\\C:\\myapp', tag='docker_app-www', rm=True, forcerm=False, pull=False, nocache=False, dockerfile='./.docker/Dockerfile-app-www', cache_from=None, labels=None, buildargs={}, network_mode=None, target=None, shmsize=None, extra_hosts=None, container_limits={'memory': None}, gzip=False, isolation=None, platform=None)
After ~10 min, it's start to build the image.
.docker/docker-compose.my.yml
version: '3'
services:
app-www:
image: 00000000.dkr.ecr.us-east-2.amazonaws.com/app-www:latest
build:
context: ../
dockerfile: ./.docker/Dockerfile-app-www
.docker/Dockerfile-app-www
FROM node:latest
WORKDIR /usr/src/app
COPY ./dist/myapp .
RUN npm install
EXPOSE 3000
CMD [ "npm", "start" ]
Upvotes: 1
Views: 6620
Reputation: 3716
It could be the build context, as stated in the docs this is sent to the docker daemon which could end up being a large transfer. From the docs (emphasis mine)
https://docs.docker.com/compose/compose-file/#context
When the value supplied is a relative path, it is interpreted as relative to the location of the Compose file. This directory is also the build context that is sent to the Docker daemon.
The way to tell would be to point to a folder with nothing in it and a simplified Dockerfile and see if that starts faster.
Upvotes: 2