docker-archive / toolbox

The Docker Toolbox
https://docker.com/toolbox
3.22k stars 1.23k forks source link

"docker build" immediately hangs indefinitely. Windows 10 #613

Closed JDudzik closed 5 years ago

JDudzik commented 7 years ago

When I attempt to run a build command, docker simply freezes before producing any output. I've allowed it to sit for large lengths of time with no success. I've tested using a fully configured dockerfile as well as using a dockerfile with nothing but "FROM ubuntu", same results. I can run docker run hello-world just fine. It downloads and executes properly. This might have something to do with virtualbox's shared folders. I created an Ubuntu box, installed docker, and when I run docker build -t testapp . from a shared folder where my dockerfile is located, I get the same hangup, yet if I execute that same build command with a dockerfile from anywhere other than a shared folder, it works properly.

This might honestly be an issue of a lack of my own knowledge or understanding, so any help or a point in the right direction is appreciated.

Running Windows 10.0.14393 Results from "Docker Version", "Docker Info", and "systeminfo" commands

settoloki commented 7 years ago

Having the same issue, I resolved it once by uninstalling and reinstalling docker. However to do this each time I need to build my containers would be a chore.

Windows 10 Pro using Hyper V

Issue: building a container freezes and does not build the container. I have noticed a delay previously before a container is built if COPY or ADD are used, presumably where it is doing some sort of preflight before sending the files to the VM. This freezes at the same place but even after being left for over an hour does not progress.

expected: Docker to build image.

fixes The first time this happened I uninstalled and reinstalled docker, it then acted as expected, just come to build more containers (roughly a week later) and now they will not build again.

Other notes: since the reinstall I have noticed docker complains about there not being enough memory to start when I first boot up my laptop, however there is ample memory and it only uses 2GB, a delayed start fixes this.

Docker Info

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 115
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: MIQU:EPM5:4JNJ:GRQG:DZD4:LMGH:M3EP:N7FI:4OQY:YJWN:4Q53:QXQ4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 14
 Goroutines: 24
 System Time: 2017-02-17T11:39:17.7000773Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Docker Version

$ docker version
Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 08:47:51 2017
 OS/Arch:      windows/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 08:47:51 2017
 OS/Arch:      linux/amd64
 Experimental: true

Log after running $docker build -t tag/tag

[11:47:34.449][FeedbackSettings][Info   ] Open logs
[11:48:11.279][ApiProxy       ][Info   ] proxy >> GET /_ping
[11:48:11.280][ApiProxy       ][Info   ] Dial Hyper-V socket 624a5d6e-45b1-454b-9513-b5bdd3069825:23a432c2-537a-4291-bcb5-d62504644739
[11:48:11.280][ApiProxy       ][Info   ] Successfully dialed Hyper-V socket 624a5d6e-45b1-454b-9513-b5bdd3069825:23a432c2-537a-4291-bcb5-d62504644739
[11:48:11.281][ApiProxy       ][Info   ] proxy << GET /_ping

A diagnostic was uploaded with id: C248498C-1F29-4BB5-997D-8BB962FD27AB/2017-02-17_11-49-05

Baggerone commented 7 years ago

In case this helps ... I've had the same problem. However, if I have a docker-compose.yml file with a block that only does a build, that works fine. E.g.

web:
  build: .

> docker-compose up -d web

kWhittington commented 7 years ago

@Baggerone I'm having the same problem with an older version of docker on OS X 10.12.3. docker build . hangs but changing docker-compose.yml to give the web image build: . will build the Dockerfile I want to build with docker build . via docker-compose up -d web.

Really weird.

» docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 21:49:11 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.4
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   1564f02
 Built:        Tue Dec 13 02:47:26 2016
 OS/Arch:      linux/amd64
zippy1981 commented 7 years ago

I had a similar problem. I ran procmon and filtered for all docker processes.

Filters.

I discovered that during this time, docker was reading EVERY file in my git repo. I had a lot of files that didn't need to be there. I deleted a lot of files and added others to .dockerignore that sped up the process.

Procmon window

orobardet commented 7 years ago

Had the same issue. Based on @zippy1981 comment, I added .git directory in my '.dockerignore` file, and it solve the problems.

Did not have the problem building in a Linux environnement (even on a VM mounting the local windows filesystem).

boukeversteegh commented 6 years ago

My MobiLinuxVM image was on the default C:\ location, which had only 2GB of free space remaining. After moving the image (Through docker settings) to another partition with plenty (200GB) of space, I could build quickly

dkocich commented 6 years ago

this was a case for me with huge node_modules folder. Creating .dockerignore (and ignoring node_modules) in the same folder as Dockerfile solves it. The issue is described also e.g. here https://stackoverflow.com/questions/26600769/build-context-for-docker-image-very-large

NicksonYap commented 6 years ago

(edit: just realised this is Docker Toolbox, I was using Docker For Windows)

For Me, Stopping Windows Defender Real-time Protection helped

Did not have .dockerignore and did not do anything with my node_modules

auberryberry commented 6 years ago

I’m seeing this on a surface book 2 (few days old), Windows 10 build 1803.

‘Docker build’ just hangs with no output Docker-compose doesn’t work, running it with verbose shows it checking for the image, seeing 404 then calling the Docker build proxy and again just hanging.

Docker run works fine, something about the docker build command completely shafted.

Tried putting the docker file in a different place, also tried a one line docker file FROM Ubuntu with no joy.

dazinator commented 6 years ago

I am seeing this today on my windows 10 machine. Not sure what has changed, has previoulsy been working fine, perhaps it was the last windows update.

Docker build just hangs. Reinstalling docker has not fixed it. Docker-Compose build also just hangs. No output whatsoever have to close the terminal. Not sure how to proceed.

auberryberry commented 6 years ago

@dazinator, what windows build are you running and docker build? Have you checked the logs after running the command , are you just seeing ping?

dazinator commented 6 years ago

This is what I am seeing (this windows has been stuck like this now for 16 hours):

image

Note I did a docker pull first which worked fine. Also note: I used to be able to press either alt + c, or ctrl + c (can't remember which) to halt a running docker command - this doesn't work either when in this state the only way to exit is to restart docker or close the terminal.

Have you checked the logs after running the command

Where are they?

Docker version:

image

System Info:

image

auberryberry commented 6 years ago

Can you have a look in your Docker logs in AppData or ProgramData, forgot which one now, see if you’re seeing a bunch of pings and then nothing.

Compose calls a docker build proxy so that’s a bust too.

On 27 Jun 2018, at 09:54, Darrell notifications@github.com<mailto:notifications@github.com> wrote:

I am seeing this (this windows has been stuck like this now for 16 hours):

[image]https://user-images.githubusercontent.com/3176632/41963506-abf09d68-79ef-11e8-8858-a41fef223757.png

Note I did a docker pull which worked fine, but the docker-compose build always hangs.

Docker version:

[image]https://user-images.githubusercontent.com/3176632/41963612-e877f632-79ef-11e8-8a77-2788b1f0ba6a.png

System Info:

[image]https://user-images.githubusercontent.com/3176632/41963648-007ab814-79f0-11e8-8973-d15468b63d76.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/docker/toolbox/issues/613#issuecomment-400595019, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYF3DQTqrRZ738CKrhc7cGYFv52Mtf4ks5uA0gzgaJpZM4LV4QW.

dazinator commented 6 years ago

Ok I found the logs - seems it does point to an error:

Version: 18.03.1-ce-win65 (17513) Channel: stable Sha1: 93354b38bd7210badafff8e0ce1f0be9a465be83 Started on: 2018/06/27 09:52:49.751 Resources: C:\Program Files\Docker\Docker\Resources OS: Windows 10 Pro Edition: Professional Id: 1803 Build: 17134 BuildLabName: 17134.1.amd64fre.rs4_release.180410-1804 File: C:\Users\darrell.tunnell\AppData\Local\Docker\log.txt CommandLine: "C:\Program Files\Docker\Docker\Docker for Windows.exe" You can send feedback, including this log file, at https://github.com/docker/for-win/issues [09:52:49.863][GUI ][Info ] Starting... [09:52:49.877][GUI ][Error ] An instance is already running. Exiting. [09:52:56.289][SegmentApi ][Info ] Usage statistic: actionMenuAbout [09:53:19.508][WindowsDaemon ][Info ] Audio Orchestrator Power Event: Battery Saver Is Not Enabled, Voice Activation Ready [09:53:19.510][WindowsDaemon ][Info ] Audio Orchestrator Power Event: Battery Saver Is Not Enabled, Voice Activation Ready [09:55:02.143][WindowsDaemon ][Info ] Updated Symantec Endpoint Protection status successfully to SECURITY_PRODUCT_STATE_ON. [09:55:02.143][WindowsDaemon ][Info ] Updated Symantec Endpoint Protection status successfully to SECURITY_PRODUCT_STATE_ON. [09:59:09.092][ApiProxy ][Info ] time="2018-06-27T09:59:09+01:00" msg="proxy >> POST /v1.25/build?t=packages.reach.co.uk%2FInfrastructure%2Fteamcityagent1&q=False&nocache=True&rm=True&forcerm=True&pull=False&dockerfile=.%2FTeamCityBuildAgent%2FDOCKERFILE\n" [09:59:09.092][ApiProxy ][Info ] time="2018-06-27T09:59:09+01:00" msg="Dial name pipe \\.\pipe\docker_engine_windows" [09:59:09.092][ApiProxy ][Info ] time="2018-06-27T09:59:09+01:00" msg="Successfully dialed name pipe \\.\pipe\docker_engine_windows" [09:59:09.101][WindowsDaemon ][Info ] debug: Calling POST /v1.25/build?t=packages.reach.co.uk%2FInfrastructure%2Fteamcityagent1&q=False&nocache=True&rm=True&forcerm=True&pull=False&dockerfile=.%2FTeamCityBuildAgent%2FDOCKERFILE [09:59:09.102][WindowsDaemon ][Info ] debug: Calling POST /v1.25/build?t=packages.reach.co.uk%2FInfrastructure%2Fteamcityagent1&q=False&nocache=True&rm=True&forcerm=True&pull=False&dockerfile=.%2FTeamCityBuildAgent%2FDOCKERFILE [09:59:09.104][WindowsDaemon ][Info ] debug: FIXME: Got an API for which error does not match any expected type!!!: invalid reference format: repository name must be lowercase [module=api error_type=errors.errorString] [09:59:09.104][WindowsDaemon ][Info ] debug: FIXME: Got an API for which error does not match any expected type!!!: invalid reference format: repository name must be lowercase [module=api error_type=errors.errorString] [09:59:09.104][WindowsDaemon ][Error ] Handler for POST /v1.25/build returned error: invalid reference format: repository name must be lowercase [09:59:09.104][WindowsDaemon ][Error ] Handler for POST /v1.25/build returned error: invalid reference format: repository name must be lowercase [09:59:09.104][WindowsDaemon ][Info ] debug: FIXME: Got an API for which error does not match any expected type!!!: invalid reference format: repository name must be lowercase [module=api error_type=errors.errorString] [09:59:09.104][WindowsDaemon ][Info ] debug: FIXME: Got an API for which error does not match any expected type!!!: invalid reference format: repository name must be lowercase [module=api error_type=errors.errorString] [09:59:09.605][ApiProxy ][Info ] time="2018-06-27T09:59:09+01:00" msg="error forwarding client's request to Docker: The pipe is being closed." [09:59:09.605][ApiProxy ][Info ] time="2018-06-27T09:59:09+01:00" msg="proxy << POST /v1.25/build?t=packages.reach.co.uk%2FInfrastructure%2Fteamcityagent1&q=False&nocache=True&rm=True&forcerm=True&pull=False&dockerfile=.%2FTeamCityBuildAgent%2FDOCKERFILE\n"

i.e repository not being lowercase? I'll try and correct that in my docker-compose.yml and see if it works.

dazinator commented 6 years ago

SO that was it.

In my docker compose yml file I had this:

image: packages.reach.co.uk/Infrastructure/teamcityagent1

This caused everything to hang.

Changing it to this:

image: packages.reach.co.uk/infrastructure/teamcityagent1

Fixes it.

A case error shouldnt really cause an indefinite hang - should this be a bug? Should be very simple to repro.

auberryberry commented 6 years ago

tiny update: deleting node_modules solved it so adding it to .dockerignore also solved it.

Kritner commented 6 years ago

I have the following in my .dockerignore, i don't know if it's just not working (the ignoring i mean), or if there's something else afoot with my dockerfile:

.dockerignore
.env
*/.git
.git
.gitignore
*/.vs
.vs
*/.vscode
.vscode
docker-compose.yml
docker-compose.*.yml
*/bin
bin
*/obj
obj
*/node_modules
node_modules

Just hangs after hitting enter on docker build -t mywhatever ..

edit: Noticed after about 10 minutes it started doing its thing, and the "prepared" filesize matched the filesize that would have been provided with node_modules being included. My node modules are located (from the perspective of the .gitignore and dockerfile in ./src/KritnerWebsite.Web/ClientApp/node_modules/, is this why it's not being picked up? i would have thought either exclusion in the above file would have caught it.

auberryberry commented 6 years ago

Quick test,

Just pull a Docker file from a repo somewhere and build see if it builds, that narrowed it down to the directory/ my thing rather than build in general.

On 22 Aug 2018, at 00:56, Russ Hammett notifications@github.com<mailto:notifications@github.com> wrote:

I have the following in my .dockerignore, i don't know if it's just not working, or if there's something else afoot with my dockerfile:

.dockerignore .env /.git .git .gitignore /.vs .vs /.vscode .vscode docker-compose.yml docker-compose..yml /bin bin /obj obj */node_modules node_modules

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/docker/toolbox/issues/613#issuecomment-414859774, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYF3ChS98acFrDDsFdoUSLUMH6Z3fcVks5uTJ4zgaJpZM4LV4QW.

HelmutPla commented 5 years ago

I have macOS Mojave, and also my docker image build command was hanging. I moved Dockerfile and other stuff into a subdirectory of my home dir (from which I was running the command before) and then the build command was running OK.

sarat1669 commented 5 years ago

I have macOS Mojave, and also my docker image build command was hanging. I moved Dockerfile and other stuff into a subdirectory of my home dir (from which I was running the command before) and then the build command was running OK.

Facing the same issue on Mojave

gustavovalverde commented 5 years ago

This should be close as using .dockerignore is the solution to this problem. Using a content like:

.git
.gitignore
LICENSE
README.md
Changelog.md
Makefile
docker-compose.yml
extra_addons/*

...solves most cases.

JDudzik commented 5 years ago

Closing this issue as it looks like the provided suggestions solve most of the causes.

AbirAbbas commented 5 years ago

Disabling Windows Defender seemed to have solved the problem, i'll try turning it back on and running docker terminal with admin privileges and see if that helps

auberryberry commented 5 years ago

Did you try any of the mitigation’s in this thread?

On 3 Mar 2019, at 01:47, André R. Martins notifications@github.com<mailto:notifications@github.com> wrote:

I still have the problem. I just ran docker build . and docker simply freezes before producing any output. My Dockerfile just have one line: FROM alpine:3.7

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/docker/toolbox/issues/613#issuecomment-468978149, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYF3Ao12gdbwKXTXBZzh4a973U2FmyGks5vSymkgaJpZM4LV4QW.

andrermartins commented 5 years ago

I write all sub-directories in the .dockerignore and it works! Thanks!

chemiu commented 5 years ago

from my experience this was due to other stuff in my folder

dluc commented 5 years ago

Encountered the same problem in MacOS, and the same Dockerfile was working when moved under /tmp. Creating a .dockerignore to ignore node_modules solved the problem for docker build ..

For some unknown reason (I assume something to do with passing the context or not) docker build - < Dockerfile works well instead, without the need to ignore folders.

So there you have a couple options:

  1. when using docker build . make sure the folder contains a .dockerignore to exclude complex folders, e.g.:
    .git
    */.git
    node_modules
    */node_modules
  2. use docker build - < Dockerfile
ericblade commented 5 years ago

it does seem that most people are seeing the issue because docker build apparently does a full scan of every file on the filesystem in the directory you're running it in. That does seem to be a bad idea, depending on what the reason for doing it is. I am seeing this right now, and haven't yet narrowed it down to what is causing the problem, but if it's because there's too many files in the directory, that's .. not good.

so docker-compose works to build it, but docker build just hangs forever, seemingly, though i've only let it run for about 5 minutes, there's no CPU or disk activity.

DanielCornea commented 5 years ago

(edit: just realised this is Docker Toolbox, I was using Docker For Windows)

For Me, Stopping Windows Defender Real-time Protection helped

Did not have .dockerignore and did not do anything with my node_modules

This helped me also

n8tb1t commented 5 years ago

I had a similar problem. I ran procmon and filtered for all docker processes.

Filters.

I discovered that during this time, docker was reading EVERY file in my git repo. I had a lot of files that didn't need to be there. I deleted a lot of files and added others to .dockerignore that sped up the process.

Procmon window

WOW, I encountered this problem, after placing like a 4gb file inside docker folder. and it stuck :)

dejan92 commented 5 years ago

Had the same issue, tried to run Dockerfile that was created in the root in C:/ . Probably docker needs to go trough all files until he finds the Dockerfile. After i moved my file in a folder on Desktop, navigate to it and run the build again it worked perfectly

n8tb1t commented 5 years ago

Had the same issue, tried to run Dockerfile that was created in the root in C:/ . Probably docker needs to go trough all files until he finds the Dockerfile. After i moved my file in a folder on Desktop, navigate to it and run the build again it worked perfectly

use .dockerignore

ericblade commented 5 years ago

Root of the problem seems to be that docker has to scan all the files in the folder it is run in. This is.. unintuitive, at best, and that it provides absolutely no indication of what it is doing or why, quite confusing to users.

marmotking commented 4 years ago

adding the .git directory to my .dockerignore solved it for me.