I am trying to find how docker build --pull/docker-compose build --pull option works.
I found a link - https://docs.docker.com/compose/reference/build/
All it says is that -
Always attempt to pull a newer version of the image.
But I still have some questions unanswered -
e.g. consider this image - mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim
When I use the --pull flag,
Would it pull aspnetcore 3.1 version if available?
Would it pull nightly build if available?
Would it always download the image regardless if the local image and the latest image are same?
What would happen if the machine doesn't have internet connectivity while running docker build --pull?
Would it pull aspnetcore 3.1 version if available?
No, because it wouldn't be tagged :3.0-buster-slim.
Would it pull nightly build if available?
No, because it wouldn't be tagged :3.0-buster-slim.
Would it always download the image regardless if the local image and the latest image are same?
No. It will download an update if the local and remote sha256 hashes differ. If they're the same it won't re-download it. There's no point.
Let's test it with a simple one-line Dockerfile:
FROM alpine:latest
First time:
$ docker build --pull .
...
latest: Pulling from library/alpine
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Downloaded newer image for alpine:latest
Subsequent builds:
$ docker build --pull .
...
latest: Pulling from library/alpine
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Image is up to date for alpine:latest
What would happen if the machine doesn't have internet connectivity while running docker build --pull?
The build fails. With networking disabled, --pull fails:
$ docker build --pull .
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM alpine:latest
Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: server misbehaving
Without --pull it works:
$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM ubuntu:latest
---> a2a15febcdf3
Successfully built a2a15febcdf3
no
no
it will always check for a new image with the name:tag mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim
it should fail with error
Related
After pushing a commit to GitLab the build pipeline starts to check the new commit. Build and Test stage run successfully. But the Deploy stage stops with the following error:
Running with gitlab-runner 12.3.0 (a8a019e0)
on gitlab-runner2 QNyj_HGG
Using Docker executor with image nexus.XXX.com/YYY/ZZZ-engines ...
Authenticating with credentials from /root/.docker/config.json
Pulling docker image nexus.XXX.com/YYY/ZZZ-engines ...
ERROR: Job failed: Error response from daemon: manifest for
nexus.XXX.com/YYY/ZZZ-engines:latest not found: manifest unknown: manifest unknown (executor_docker.go:188:0s)
What could be the reason behind that?
I had the same problem, I solved it by rebuilding and republishing the docker image that the GitLab CI file was referencing and then re-run the pipeline again and it worked.
There is no latest tag for that specific docker image. Most likely you're building using a specific tag, e.g v1.0:
docker build -t nexus.XXX.com/YYY/ZZZ-engines:v1.0 .
then using that image without a tag in your .gitlab-ci.yml:
image: nexus.XXX.com/YYY/ZZZ-engines
# OR
build-job:
stage: build
image: nexus.XXX.com/YYY/ZZZ-engines
...
To fix, either specify a tag in you ci file, or tag the image with latest when building:
docker build -t nexus.XXX.com/YYY/ZZZ-engines:v1.0 -t nexus.XXX.com/YYY/ZZZ-engines:latest .
The gitlab docker template has a nice example of how to automatically tag a build as latest on the default branch: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
$ docker pull oraclelinux
Using default tag: latest
latest: Pulling from library/oraclelinux
c93adbd5ca8c: Downloading [==================================================>] 85.96MB/85.96MB
unexpected EOF
$ docker --version
Docker version 18.09.2, build 6247962
I notice that docker pull continously retries with back-off for a few times and eventually fails with unexpected EOF. Same issue observed if pulling centos, debian image.
The docker pull of this image from a repository in local network succeeds. I'm trying to figure out the failure for pulls from github.io.
docker pull for smaller size images (ex: alpine, helloworld) succeeds.
Running Docker Desktop Version 2.0.0.3 (31259) on MacOS High Sierra. Restarting Docker did not resolve the issue.
Any pointers are greatly appreciated.
Found an answer. I had to use Manual Proxy Configuration within Docker Desktop to point to an internal corp proxy for this to work.
If you launch docker-run by yourself it works, if you do this with docker-compose it doesn't
roman#debian ~/D/O/devops> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
roman#debian ~/D/O/devops> docker-compose build app
Building app
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
roman#debian ~/D/O/devops>
Ok it's solved, previously been installing compose from repository, now installed through pip and it's working
My docker version is
Docker version 1.12.2-cs2-ws-beta, build 050b611
I am trying to build the image using command
docker build -t iis-dockerfile .
The DockerFile content is
FROM microsoft/iss
RUN echo "Hello World - Dockerfile" > C:\inetpub\wwwroot\index.html
config.json is
{
"auths": {
"https://index.docker.io/v1/": {
"auth": <somekey>
}
}
}
On running docker build, it gives error
Sending build context to Docker daemon 2.048 kB
Step 1/2 : FROM microsoft/iss
unauthorized: authentication required
I have already done docker login. That's how config.json is created. I am new to containers and following the get started tutorial https://blogs.msdn.microsoft.com/allthingscontainer/2016/09/15/windows-containers-getting-started-a-step-by-step-guide/. Any idea how can I work around this.
Also I figured out that docker pull is working for me. While this also required authentication
Just an observation. Make sure your docker file has correct base image name. Are you sure you want FROM microsoft/iss and not FROM microsoft/iis?
When I tried to create new image with correct base image. It seem to work.
Docker docker build -t test-iid .
Sending build context to Docker daemon 344.9 MB
Step 1/2 : FROM microsoft/iis
latest: Pulling from microsoft/iis
3889bb8d808b: Downloading
3430754e4d17: Downloading
7aee39cd34f9: Downloading [> ] 540 kB/122.7 MB
5b8e6b632025: Download complete
e067d71858d2: Download complete
I am using Jenkins to make build of project, but now my client wants to make builds inside of a Docker image. i have installed docker on server and its running on 172.0.0.1:PORT. I have installed Docker plugin and assigned this TCP URL to Docker URL. I have also created an image with the name jenkins-1
In configure project I use Build environment Build with Docker Container and provide image name. and then in Build in put Execute Shell and then Build it
But it gives the Error:
Pull Docker image jenkins-1 from repository ...`
$ docker pull jenkins-1`
Failed to pull Docker image jenkins-1`
FATAL: Failed to pull Docker image jenkins-1`
java.io.IOException: Failed to pull Docker image jenkins-1``
at com.cloudbees.jenkins.plugins.docker_build_env.PullDockerImageSelector.prepare DockerImage(PullDockerImageSelector.java:34)`
at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerB`uildWrapper.java:169)`
at hudson.model.Build$BuildExecution.doRun(Build.java:156)`
at `hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)`
at hudson.model.Run.execute(Run.java:1720)`
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)`
at hudson.model.ResourceController.execute(ResourceController.java:98)`
at hudson.model.Executor.run(Executor.java:404)`
Finished: FAILURE`
I just have run into the same issue. There is a 'Verbose' check-box in the configuration of build environment after selecting 'Advanced...' link to expand on the error details:
CloudBees plug-in Verbose option
In my case I ran out of space downloading the build Docker images. Expanding ec2 volume has resolved the issue.
But there is an ongoing trouble with space as docker does not auto cleans images and I have ended up adding a manual cleanup step into the build:
docker volume ls -qf dangling=true | xargs -r docker volume rm
Complete build script:
https://bitbucket.org/vk-smith/dotnetcore-api/src/master/ci-build.sh?fileviewer=file-view-default