User Tools

Site Tools


wiki:docker_troubleshooting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:docker_troubleshooting [2023/09/13 11:39] – add --chmod option requires BuildKit antisawiki:docker_troubleshooting [2023/12/01 14:04] (current) – add No internet access paragraph antisa
Line 83: Line 83:
 ===== --chmod option requires BuildKit ===== ===== --chmod option requires BuildKit =====
 Might happen when using ansible's docker_image module. It does not support the ''--chmod'' option in the ''ADD'' instruction. Just remove the chmod part and add a separat ''RUN'' command that runs ''chmod'' Might happen when using ansible's docker_image module. It does not support the ''--chmod'' option in the ''ADD'' instruction. Just remove the chmod part and add a separat ''RUN'' command that runs ''chmod''
 +
 +=====   stderr: 'failed to solve: failed to compute cache key: failed to calculate checksum ... no such file or directory' =====
 +Make sure that the files (app files, folders etc.) that the Dockerfile is suppose to copy are in the project root directory, where the Dockerfile file is (or docker compose file).
 +
 +===== No internet access when building an image =====
 +In an alpine image this might manifest for example (run inside the virtualbox VM) :
 +
 +<code>
 +fatal: [10.21.21.11]: FAILED! => changed=false                                                                                                                                                                     
 +  msg: 'Error building my/container - code: 2, message: The command ''/bin/sh -c apk add --no-cache libc6-compat git'' returned a non-zero code: 2, logs: [''Step 1/31 : FROM node:18.18.2-alpine AS deps''
 +, ''\n'', '' ---> 1646380c3156\n'', ''Step 2/31 : RUN apk add --no-cache libc6-compat git'', ''\n'', '' ---> Running in 567cff6b368f\n'', ''fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.
 +tar.gz\n'', ''fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz\n'', ''\x1b[91mWARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.18/main: temporary error (try again late
 +r)\n\x1b[0m'', ''\x1b[91mWARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.18/community: temporary error (try again later)\n\x1b[0m'', ''\x1b[91mERROR: unable to select packages:\n  git (no such package
 +):\n    required by: world[git]\n  libc6-compat (no such package):\n    required by: world[libc6-compat]\n\x1b[0m'', ''Removing intermediate container 567cff6b368f\n'']'                                          
 +           
 +</code>
 +
 +To test try adding ping in Dockerfile:
 +  
 +  ...
 +  RUN ping -c 4 8.8.8.8
 +  ...
 +If you get a packet loss that means the docker can't access the Internet. Try first restarting the docker e.g.
 +
 +  systemctl restart docker
 +  
 +If this doesn't work you can build the image with ''--network host'' argument:
 +
 +  docker build --network host -t test1 -f Dockerfile .
 +
 +In ansible task this looks like:
 +
 +<code>
 +...
 +- name: "Build the docker image"
 +  docker_image:
 +    name: "{{ full_app_name }}:{{ buildNo }}"
 +    repository: "{{ full_app_name }}:latest"
 +    state: present
 +    build:
 +      path: "{{ deploy_helper.new_release_path }}"
 +      network: host
 +    force: "{{ not (disable_image_force_build | default(false)) }}"
 +...
 +</code>
 +==== Tested on ====
 +  * Virtualbox VM Debian 11 Jessie (building inside of this VM)
 +  * ansible 2.9.27
 +  * docker 24.0.7
  
 ====== See also ====== ====== See also ======
wiki/docker_troubleshooting.1694597942.txt.gz · Last modified: 2023/09/13 11:39 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki