Skip to content

Instantly share code, notes, and snippets.

@leolin310148
Last active November 22, 2019 12:46
Show Gist options
  • Save leolin310148/e545438aecba9cc4c9c313ee2c2ed8bb to your computer and use it in GitHub Desktop.
Save leolin310148/e545438aecba9cc4c9c313ee2c2ed8bb to your computer and use it in GitHub Desktop.
solve "error initializing graphdriver: loopback attach failed" for docker-in-docker

Create loopback.sh in tmp

#!/bin/bash
ensure_loop(){
  num="$1"
  dev="/dev/loop$num"
  if test -b "$dev"; then
    echo "$dev is a usable loop device."
    return 0
  fi
  echo "Attempting to create $dev for docker ..."
  if ! mknod -m660 $dev b 7 $num; then
    echo "Failed to create $dev!" 1>&2
    return 3
  fi
  return 0
}
LOOP_A=$(losetup -f)
LOOP_A=${LOOP_A#/dev/loop}
LOOP_B=$(expr $LOOP_A + 1)
ensure_loop $LOOP_A
ensure_loop $LOOP_B

sh /tmp/loopback.sh

Thank you from https://www.xdelve.com/article/80.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment