Skip to content

Instantly share code, notes, and snippets.

@mariocesar
Last active April 5, 2023 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariocesar/e1eb6ddf721cb024a093136d633275f4 to your computer and use it in GitHub Desktop.
Save mariocesar/e1eb6ddf721cb024a093136d633275f4 to your computer and use it in GitHub Desktop.
Docker command and utils.

Useful Docker commands

Show all the files in a docker volume, use: docker-list-volume-contents volume_name

function docker-list-volume-contents() {
    docker run --rm -v ${1}:/data -it alpine find /data -type f
}

Output the entrypoint content if it exists: docker-show-entrypoint-contents image_name

function docker-show-entrypoint-contents() {
  local image_name=$1
  local entrypoint=$(docker inspect --format='{{json .Config.Entrypoint}}' "$image_name")

  if [ -z "$entrypoint" ] || [ "$entrypoint" = "null" ]; then
      echo "Entrypoint: Not found"
  else
      local entrypoint_script=$(echo "$entrypoint" | jq -r '.[]' | base64 --decode)
      echo "Entrypoint:"
      echo "$entrypoint_script"
  fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment